So I have an activity in which I have multiple dynamically allocated/created copies of a Fragment:
I want to be able to set each of the times via their separate buttons, but I'm currently a little confused on how I know which button/textView I'm working with. I need to use an onClickListener (as discussed here) and to use that, I would need to recognize a button (with an XML-defined ID) in code. But, R.id.buttonID
wont work because all of those buttonID's associate with the same integer ID, so I'm not exactly sure how to uniquely recognize each of the buttons (and text views) in this case. I thought that I could maybe store the location of the fragments in an array or ordered container, but I don't think that will help in identifying each fragment's inner pieces. Any help is appreciated, thanks.
This is my XML. I'm not sure if at all how this will help, but here! My java doesn't have anything in it, otherwise I would post it.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".UpcomingCycleFragment"
android:padding="5dp"
android:id="@+id/upCycleFrag">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="10dp"
android:layout_margin="3dp"
android:gravity="center"
android:id="@+id/upcomingTime"
android:text="--:-- AM"
android:textSize="15pt"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="10dp"
android:orientation="vertical"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/upcomingDuration"
android:text="0m long"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/upcomingEnd"
android:text="Ends at --:--pm"/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_gravity="right|center_vertical"
android:id="@+id/thisbuttonsucks"
android:text="Edit Time"
/>
</LinearLayout>
</FrameLayout>