I am using import android.support.v4.app.ListFragment
to create a ListFragment. Inside the fragment itself -- not the parent activity -- I want to implement the onItemClick
method. Will someone please provide a simple example on how this might work?
public class MyListFragment extends ListFragment {
Spannable[] stuff = {};//to be filled
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ArrayAdapter<Spannable> adapter = new ArrayAdapter<Spannable>(inflater.getContext(), android.R.layout.simple_list_item_1, stuff);
setListAdapter(adapter);
return super.onCreateView(inflater, container, savedInstanceState);
}
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
//this is red underlined by eclipse
}
}