I have used the code below to add a LinearLayout dynamically.
Public Zero sendMessage02 (see see) {view.getId (); EditText EditText = (Edit Text) Find VVBIID (RaidAdit_message); String message = editText.getText (). ToString (); LinearLayout l = (LinearLayout) findViewById (R.id.layout_odd); Textview text = new textview (this); Text.setText (message); Text.setLayoutParams (new layout paragraph (layout perm. WRAP_CONTENT, layout para. WRAP_CONTENT)); L.addView (text); LinearLayout l2 = (LinearLayout) findViewById (R.id.layout01); L2.addView (L); } When I run my application, this emulator error says that the application is unfortunately closed.
What am I doing wrong? There is no other way to dynamically add layouts.
With this example you are not attempting to insert a LinearLayout. You get a reference to your existing linear layout
LinearLayout l = (LinearLayout) findViewById (R.id.layout_odd); and adding a TextView to it
l.addView (text); If you want to add a linear line by adding, then you refer to your view group and attach a new liner layout for it.
You can make your linear layout a brand new example: linear layout l = new linerlayout (reference); Or moving from a layout resource:
linear level l = matching inflection (). Flowers (R.Letite.m_lnir_layout); and then attach it to your ViewGroup
ViewGroup root = findViewById (R.id.my_view_group); Root.addView (l);
Comments
Post a Comment