Click Listener not invoked within ListFragment
Posted
by
membersound
on Stack Overflow
See other posts from Stack Overflow
or by membersound
Published on 2012-05-30T15:53:22Z
Indexed on
2012/05/30
16:41 UTC
Read the original article
Hit count: 181
I'm extending a SherlockListFragment, but it should not matter as my question seems to be more general related to Fragments.
Now, I implement a simple click listener for my list, but it does not get called.
public class MyListFragment extends SherlockListFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.list, container, false);
v.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
Log.i("debug", "single click");
}
});
return v;
}
}
Is anything wrong with this?
//Solution:
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Log.i("debug", "single click");
}
});
© Stack Overflow or respective owner