android - Inflating Layout trouble -
i trying add view dynamically relative layout. view not multyling code using enclosing...
for (int i=0;i<mthumbids.length-1;i++) { try { relativelayout containerlinearlayout = (relativelayout)findviewbyid(r.id.maincontainer); view child = getlayoutinflater().inflate(r.layout.single_row, null); containerlinearlayout.addview(child); }catch (exception e){ toast.maketext(getapplicationcontext(),"dkljf"+e.getmessage(),toast.length_short).show(); } }
activitymain.xml
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" tools:context=".mainactivity" android:orientation="vertical"> <button android:layout_width="wrap_content" android:layout_height="wrap_content" /> <button android:layout_width="wrap_content" android:layout_height="wrap_content" /> <scrollview android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/scrollview" > <relativelayout android:id="@+id/maincontainer" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"> </relativelayout> </scrollview>
single_row.xml
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <linearlayout android:id="@+id/main" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <linearlayout android:id="@+id/oddcontainer" android:layout_width="fill_parent" android:layout_height="150dp" android:orientation="horizontal" android:layout_weight="1" android:background="#f00"> </linearlayout> <linearlayout android:id="@+id/evencontainer" android:layout_width="fill_parent" android:layout_height="150dp" android:orientation="horizontal" android:layout_weight="1" android:background="#f0f"> </linearlayout> </linearlayout>
you can use listview or recyclerview
Comments
Post a Comment