我在带有自定义单元格适配器的片段中有一个列表,
问题是 onItemSelected 没有响应,
请问如何解决这个问题?
public class PhoneMenuList extends SherlockFragment implements OnItemSelectedListener {
Fragment newContent = null;
ListView productList;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
View mView = inflater.inflate(R.layout.list, container, false);
return mView;
}
@Override
public void onActivityCreated(Bundle savedInstanceState){
super.onActivityCreated(savedInstanceState);
//SET THE LIST ADAPTER!
Hamburger hambu_data[] = new Hamburger[] {
new Hamburger(R.drawable.icon_hambu_folder, "My Documents"),
new Hamburger(R.drawable.icon_hambu_favs, "Top 10 viewed"),
new Hamburger(R.drawable.icon_hambu_validate, "Validate Document"),
new Hamburger(R.drawable.icon_hambu_how, "How to use"),
new Hamburger(R.drawable.icon_hambu_about, "About")
};
productList= (ListView) getActivity().findViewById(R.id.listView1);
HamburgerAdapter adapter = new HamburgerAdapter(getActivity(), R.layout.hamburger_item_row, hambu_data);
productList= (ListView) getActivity().findViewById(R.id.listView1);
View header = (View)getLayoutInflater(savedInstanceState).inflate(R.layout.hamburger_item_row, null);
productList.addHeaderView(header);
productList.setAdapter(adapter);
//listener
productList.setOnItemSelectedListener(this);
}
//@Override
public void onListItemClick(ListView l, View v, int position, long id) {
Log.d("mensa", "chapuzea");
}
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Log.d("mensa", "abacus");
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
Log.d("mensa", "semper");
}
}