well thats fine addView() did work but how to set the other properties
programmically
specially

    android:layout_width="fill_parent"
    android:layout_height="wrap_content"

as if  i did not set these properties addView will add all the new
views in the same line (i tried it on a linear layout)....

here is my code that add components

but i cant switch to the next line.....

                                        LinearLayout layout = new 
LinearLayout(getApplicationContext());
                                        TextView label = new 
TextView(getApplicationContext());
                                        EditText txt = new 
EditText(getApplicationContext());
                                        label.setText("untitled");
                                        label.setPadding(5, 3, 10, 3);
                                        layout.addView(label);
                                        layout.addView(txt);


                                        LinearLayout container = (LinearLayout) 
findViewById
(R.id.compDetails);
                                        container.addView(layout);






On Mar 10, 2:28 am, Sundog <[email protected]> wrote:
> addView() is what you're looking for.
>
> On Mar 9, 2:51 pm, Lucius Fox <[email protected]> wrote:
>
> > Fromhttp://d.android.com/guide/topics/ui/declaring-layout.html, it said
> > "Instantiate layout elements at runtime. Your application can create
> > View and ViewGroup objects (and manipulate their properties)
> > programmatically."
>
> > Can you please tell me how/where I can find example for that?
>
> > For example, how can I convert the following layout into Java code of
> > my MyWidget. So that when I put "<MyWidget...>" in my layout xml file,
> > it will automatically build a Gallery inside the MyWidget?
>
> >  <MyWidget android:id="@android:id/wigetId"
> >            android:layout_width="fill_parent"
> >             android:layout_height="wrap_content">
>
> >                 <LinearLayout
> >     android:orientation="vertical"
> >    android:layout_width="fill_parent"
> >     android:layout_height="fill_parent">
>
> >         <com.mycompany.widget.MyGallery android:id="@+id/gallery"
> >        android:layout_width="fill_parent"
> >         android:layout_height="wrap_content"
> >         />
>
> >         </LinearLayout>
>
> >         </MyWidget>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to