I have one fragment activity include two list fragments. I use D-pad to moving through lists. For example, when I click on listview1->tv, in listview2 shows tv channels . When I click listview1->movie, in listview2 shows movies list and so on.
So this is my problem: when I click listview1->item3 (item3 is highlighted now by a selector) and go to listview2 and use d-pad up/down to surf the items then I come back to listview1, by left arrow key, I expect to going back to listview->item3. But it's not the case and I can't gust witch item in listview1 will focused (highlighted)
I can't handle the focused item, I need to go back to last selected item (getListView().getSelectedItemPosition()) has true item position number but focused/hilighted is not in true/last postion)
Android 2.3.4
I used these methods but none worked
getListView().setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean focused) {
// TODO Auto-generated method stub
if (!focused) allowfocus=true;
if (focused && allowfocus){
getListView().setSelection(PosHolder.MENU_LAST_POS);
OR
getListView().setSelection(getListView().getSelectedItemPosition());
OR
getListView().getSelectedView().setSelected(true);
OR
getListView().getSelectedView().requestFocus();
Toast.makeText(getActivity(), "Menu Got Focused:"+ getListView().getSelectedItemPosition(), Toast.LENGTH_SHORT).show();
}
}
});
What worked for me was to create a customListView which inherits from the original ListView, and then override the OnFocusChange Event to handle your focus in there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With