I'm used to Java Layouts and don't really like XML, so I'm trying to create a simple screen with a top piece, that has a text("Title") and a editText that will allow you to edit the title, then a text(body) with a larger EditText for a body text, basically the same as done in the NotePad activities except with code instead of XML. I've tried the code and I keep getting a crash, maybe I'm just thinking in java too much, but can anyone point out my flaw?
LinearLayout titleContainer = new LinearLayout(this); LinearLayout bodyContainer = new LinearLayout(this); LinearLayout mainContainer = new LinearLayout(this); TextView titleText = new TextView(this); EditText titleEdit = new EditText(this); TextView bodyText = new TextView(this); EditText bodyEdit = new EditText(this); titleText.setText("Title"); titleEdit.setText("Enter Title Here:"); bodyText.setText("Body"); bodyEdit.setText("Enter Body Here:"); titleContainer.setOrientation(LinearLayout.VERTICAL); bodyContainer.setOrientation(LinearLayout.HORIZONTAL); titleContainer.addView(titleText, new LinearLayout.LayoutParams (LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0)); titleContainer.addView(titleEdit, new LinearLayout.LayoutParams (LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1)); bodyContainer.addView(bodyText, new LinearLayout.LayoutParams (LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0)); bodyContainer.addView(bodyEdit, new LinearLayout.LayoutParams (LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1)); mainContainer.addView(titleContainer, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0)); mainContainer.addView(bodyContainer, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1)); setContentView(mainContainer); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---