一個適配器類事件我有一個類數組適配器中,我有3場和一個複選框 我想SHW點擊每個TextView的事件,我的代碼下面給出瞭如何開火這一類單擊事件。我很困惑單擊在android系統
public class ItemReportAdapter extends ArrayAdapter<SalesForce>{
private LayoutInflater li;
public ItemReportAdapter(Context context,List<SalesForce> items){
super(context,0,items);
li=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public View getView(int position,View convertView,ViewGroup parent){
final SalesForce item=getItem(position);
View v=convertView;
if(v==null){
v=li.inflate(R.layout.sfreportview,null);
}
final TextView idView=(TextView)v.findViewById(R.id.itemID);
if(idView!=null){
idView.setText(""+item.getUserID());
}
idView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
popup();
}
private void popup() {
//what to write in here so as i can be shifted to other drill down
}
});
final TextView captionView=(TextView)v.findViewById(R.id.itemCaption);
if(captionView!=null){
captionView.setText(item.getName());
}
final TextView typeView=(TextView)v.findViewById(R.id.itemType);
if(typeView!=null){
typeView.setText(item.getUserType());
}
final CheckBox chkbox=(CheckBox)v.findViewById(R.id.checkboxes);
chkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
popup();
}
private void popup() {
// TODO Auto-generated method stub
}
});
return v;
}
public long getItemId(int position){
return getItem(position).getUserID();
}
public boolean hasStableIds(){
return true;
}
我想點擊idView上的事件我該怎麼做? 任何幫助,將不勝感激感謝名單!1 :)
看來你已經有idView的點擊事件,不是嗎? – kosa 2012-01-03 06:02:47
'idView.setOnClickListener(新OnClickListener()'是不是點擊監聽?也許你可以改一下你的問題,因爲它聽起來像你已經擁有你所要求的東西。 – 2012-01-03 06:06:14
ManishGupta我知道這是當我點擊聽者但想使用意圖去隔壁班的它禁止我這樣做 idView.setOnClickListener(新OnClickListener(){ @覆蓋 公共無效的onClick(視圖v){ 彈出();} 私人無效彈出() { 這裏寫什麼以便我可以轉移到下一個班級文件 } }); – 2012-01-03 06:09:57