I created a fragment layout that contains three number pickers. I used to use this fragment twice within activity_main.xml. Both sets of numberpickers appear properly, but I am unsure how to manipulate them programmatically because I don't know how to refer to each number picker individually. Basically, I am wondering if it is possible to refer to each numberpicker separately , given my current layout implementation.
The picker_fragment.xml code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/picker_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal" >
<NumberPicker
android:id="@+id/redPicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<NumberPicker
android:id="@+id/greenPicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<NumberPicker
android:id="@+id/bluePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
the activity_main.xml code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.colorpickertwo.MainActivity"
tools:ignore="MergeRootFrame" >
<include layout="@layout/picker_fragment"/>
<include layout="@layout/picker_fragment"/>
</LinearLayout>
I could just abandon my picker_fragment, or make a second fragment layout in order to give the second set of numberpicker's separate IDs, but my current implementation seems cleaner.
Thanks very much!