I have a ListView with items that will navigate on click.
The list item has two text views, which have the following click handlers:
private OnClickListener playClickListener() {
return new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), TestActivity.class);
startActivity(intent);
}
};
}
Unfortunately this leads to TestActivity firing up as many times as the user clicks intbetween int loading. I tried setting the click handers to null with setOnClickListener(null). However when I navigate back to the activity the list item is then no longer clickable.
Is there a nice work around for this?
You can try and use
startActivityForResult().and in your TestActivity you can override finish to do the following:
This will lead to the click being fired only once until the next activity returns and “re-enables” the click functionality.
–OR–
You could be boring and keep the boolean and simply “reset” it on onResume():
You should really be boring, but it’s always fun to use cross Activity callbacks. 🙂