Hi onListItemClick for listview is not working. Here i am fetching datas from SQLite using AsyncTask and displaying it in a list view. And i wants to do some actions when a
I struggled with this for a while - none of the provided solutions worked for me. In the end I found that having a call to getListView()
in my onViewCreated()
method did the trick, although I have no idea why. This is for a Fragment rather than an Activity; not sure if this makes any difference.
public class NewsListFragment extends ListFragment {
private ListView listView;
...
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
newsListView = getListView();
}
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
// this now works as expected
}
}