Add Linear Layout view dynamically in eclipse android -
how can add view (with linear layout id/linearlayout_tambahkeluhan can add automatically when click button id/tambah_keluhan) in case that...the content in linearlayout_tambahkeluhan id/layout_keluhan, id/layout_status, id/layout_tindakan...how code in java? can me? thx before
<linearlayout android:id="@+id/linearlayout_tambahkeluhan" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/layout_keluhan" > <textview android:id="@+id/textview11" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2" android:text="keluhan" android:textcolor="@color/blue" /> <textview android:id="@+id/textview12" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="0.5" android:text=":" android:textcolor="@color/blue" /> <spinner android:id="@+id/spinner_keluhan" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="4" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/layout_status" > <textview android:id="@+id/textview13" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2" android:text="status" android:textcolor="@color/blue" /> <textview android:id="@+id/textview14" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="0.5" android:text=":" android:textcolor="@color/blue" /> <spinner android:id="@+id/spinner_status" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="4" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/layout_tindakan" > <textview android:id="@+id/textview15" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2" android:text="tindakan" android:textcolor="@color/blue" /> <textview android:id="@+id/textview16" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="0.5" android:text=":" android:textcolor="@color/blue" /> <edittext android:id="@+id/edittext_tindakan" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="4" android:ems="10" android:textcolor="@color/black" /> </linearlayout> </linearlayout> <button android:id="@+id/button_tambahkeluhan" style="?android:attr/buttonstylesmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:background="@android:color/transparent" android:onclick="onclick" android:text="tambah keluhan" android:textcolor="@color/blue" android:textstyle="italic" />
you try addview(view view) function) view can controls or xml layout. example: ((linearlayout)findviewbyid(r.id.linearlayout_tambahkeluhan)).addview(btnnew);
Comments
Post a Comment