我有一个带有textview和spinner的listview,它对list中的每个微调器都有相同的值.textview和spinner的两个值分别在xml文件中。如何为微调器中的每一行选择微调器值...根据相对textview ...我完全初学到安卓...
答案 0 :(得分:0)
在WhateverAdapter
中添加以下方法:
public void setOnSpinnerItemSelectedListener(OnItemSelectedListener listener){
this.mSpinnerItemSelectedListener = listener;
}
在getView()
方法中:
public View getView(int position, View convertView, ViewGroup parent){
//...
viewHolder.spinner.setOnItemSelectedListener(mSpinnerItemClickListener);
//.....
return convertView;
}
然后在Activity
或任何地方:
MyAdapter adapter = new MyAdapter(Context....);
adapter.setOnSpinnerItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
// your code here
}
@Override
public void onNothingSelected(AdapterView<?> parentView) {
// your code here
}
});
myListView.setAdapter(adapter)