I have a layout that consists of 3 contiguous ListViews. Selecting an item in the left most list will start the second list, and so on. I am trying to begin the fragment with the first item in the left most list selected, and because a lot of logic is required, I am attempting to trigger on click instead of redo-ing all the logic. I am using this:
mListView.performItemClick(mListView, 0, mListView.getItemIdAtPosition(0));
Is what I am attempting possible? and if it is, where do I call this?
ANSWER:
So it seems that the reason this wasn't working for me is because I was manually highlighting a View within the row View and it wasn't instantiated yet (or something like that).
I used this code to call it after the ListView was laid out:
mListView.post(new Runnable() {
@Override
public void run() {
mListView.performItemClick(mListView, 0, mListView.getItemIdAtPosition(0));
}
});
EDIT:
I have 4 lists that depend on data being sent from the previous ones before being instantiated, and for some strange reason, this runnable method only works for the first list. For the others, I used this answer: https://stackoverflow.com/a/15399035/1549672. Also, strangely enough, this does not work on the first list. All the lists are nearly identical.