I have a custom xml view which, when a button is tapped, a duplicate is created into the main view.
Button addButton = (Button) findViewById(R.id.btnAdd);
addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LinearLayout newCard = (LinearLayout) getLayoutInflater().inflate(R.layout.vehicle, null);
cardLayout.addView(newCard);
final int thisCarId = new Random().nextInt(10000);
}
});
A user can tap the addButton as many times as he/she wants, and I produce a new newCard each time.
Each newCard has an ImageButton, and an EditText; when the ImageButton is tapped, I start a Camera intent with Result:
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePictureIntent, thisCarId);
Later in this activity class, I anticipate the result of the Camera activity:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.v("car", "The ID that was returned: " + requestCode);
}
My log DOES properly ascertain which instance of newCard, by way of the thisCardId... but how can I tell which newCard was created, so that I can set the ImageButton found in that newCard layout to match the camera photo? Assigning the photo is no problem... just, I don't know which one to assign it, because onActivityResult is out-of-scope, and so far as I can tell, I can't assign an anonymous Override for the activity as a whole...