Android generate Layout dynamically -
i've create layout dynamically in android screen showing list of items. know can use listview , custom adapter items in list must shown in different ways according data , i'd know if can generate layout code.
i'm trying way can see last item screen...seems other suppressed last.
here's screen code:
<?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:fab="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginbottom="50dp"> <linearlayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginbottom="50dp"> <relativelayout android:id="@+id/allitemsloadingpanel" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center"> <progressbar android:layout_width="wrap_content" android:layout_height="wrap_content" android:indeterminate="true" /> </relativelayout> <linearlayout android:id="@+id/allitemscontainer" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:paddingtop="10dip" /> </linearlayout> <com.refractored.fab.floatingactionbutton android:id="@+id/allitemsfab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|right" android:layout_margintop="16dp" android:layout_marginleft="16dp" android:layout_marginright="16dp" android:layout_marginbottom="66dp" android:src="@drawable/ic_action_add" android:visibility="gone" fab:fab_size="normal" fab:fab_colornormal="@color/appcolorprimary" fab:fab_colorpressed="@color/appcolorprimarypressed" fab:fab_colorripple="@color/appcolorprimarypressed" /> </framelayout>
and here's layout of single item inflate , add lynearlayout called "allitemscontainer":
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingtop="10dp" android:paddingbottom="10dp"> <textview android:id="@+id/allitemsitetitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="16sp" android:gravity="center_vertical" android:textstyle="bold" android:layout_alignparenttop="true" /> <textview android:id="@+id/allitemsiteusername" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="14sp" android:layout_below="@+id/allitemsiteusername" android:layout_alignparentright="true" android:layout_alignparentend="true" android:paddingright="10dp" /> <textview android:id="@+id/allitemsitetext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="12sp" android:layout_below="@+id/allitemsitetitle" android:layout_alignparentright="true" android:layout_alignparentend="true" android:paddingright="10dp" /> <ratingbar android:id="@+id/allitemsiteratingbar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:numstars="5" android:stepsize="0.1" android:layout_below="@+id/allitemsitetext" android:layout_alignparentend="true" android:layout_alignparentright="true" android:scalex="0.5" android:scaley="0.5" android:layout_marginright="-50dp"/> <relativelayout android:id="@+id/allitemscomments" android:layout_width="match_parent" android:layout_height="match_parent" /> </relativelayout>
at end of loop items i've added items lynearlayout can see one... can me?
yes can generate layout code can have linearlayout defined in layout. add view linearlayout using .addview(view)
ex:
textview textview = new textview(this) linearlayout.addview(textview);
Comments
Post a Comment