i new android development.
i want create screen has horizontal scroll view of buttons (group names). every time click group name, display members below these buttons (i assume have create fragment listview of members. haven't gotten last part. able create horizontal scroll view in xml , add 6 button xml file. want use java find number of groups every time oncreate called, can create appropriate number of buttons based on groups. (group names stored in temporary arraylist (for testing purposes) , use arraylist.size() number of buttons needed created. difficulty having figuring out how create these buttons inside linearlayout inside horizontalscrollview inside relativelayout. messed around creating 1 layout adding button, don't know how create nested layouts, or access linearlayout in want create buttons using java. here xml file (i created 1 button testing. button location want create buttons using java. don't want have written there in xml if possible. everytime new group created, button has created):
<?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="match_parent" android:background="#ffbb00"> <horizontalscrollview android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/horizontalscrollview" android:layout_alignparentleft="true" android:layout_alignparentstart="true" > <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:id="@+id/buttonlist"> <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="click me 1" android:id="@+id/button" android:layout_alignparenttop="true" android:layout_alignparentleft="true" android:layout_alignparentstart="true" /> </linearlayout> </horizontalscrollview> </relativelayout> how add buttons using java class in linearlayout?
use link how add button dynamically in android? , there way doing using loop, read article making button using loops
Comments
Post a Comment