I have a list view which contains a TextView for each list item. I need to take a picture onItemClick of the listView. onActivityResult of the ACTION_IMAGE_CAPTURE intent and updating the listview , I start another activity for result. The problem I am facing is that all the textviews in my list view are getting reset when I come back to the activity onActivityResult from the second activity. Can you please help me with this. This is my onItemClick
public void onItemClick(AdapterView<?> arg0, View v, int index, long arg3) {
selectedIndex = index; //selectedIndex is a class level variable
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File f = createImageFile();
if (f != null) {
imageFileName = f.getAbsolutePath();
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
}
startActivityForResult(takePictureIntent, 1);
}
}
This is my onActivityResult
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1 && resultCode == RESULT_OK) {
View v = listView.getChildAt(selectedIndex
- listView.getFirstVisiblePosition());
TextView textView = (TextView) v.findViewById(R.id.textView1);
int quantity = Integer
.parseInt(textView.getText().toString().trim().length() > 0 ? quantityTV
.getText().toString() : getString(R.string._0));
quantity++;
textView.setText(String.valueOf(quantity));
listViewAdapter.notifyDataSetChanged();
Intent intent = new Intent();
intent.setClass(getApplicationContext(), NotificationActivity.class);
intent.putExtra("Value1", "0");
startActivityForResult(intent, 100);
}
else if (requestCode == 100) {
// do nothing
}
}