EDIT: Found my answer in this post: https://stackoverflow.com/a/28304164/2911440
I'm trying to initialize functions from a button inside a CardView.
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24sp"
<Button
android:id="@+id/btnStart"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="startFunctionClick"
android:text="START" />
But in my attempt to find an identifier for which function/class to run(that is, which button I have pressed) it gave the same result for all four buttons. I'm creating the cards from this dataset:
private String[] dataSet = {"Face Detection", "Circle Detection", "Foreground Detection", "Color Detection"};
I'm trying to use the TextView on the same card to identify which class to initialize. But the Toast will only output "Face Detection"
public void startFunctionClick(View v) {
TextView t = (TextView) findViewById(R.id.title);
String s = t.getText().toString();
Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
//initialize class....
}
Any ideas to what I can do different?