标签:
1 button1.setOnclickListener(new View.OnClickListener() { 2 @override 3 public void onClick(View v) { 4 //balabalabala... 5 } 6 }); 7 button2.setOnclickListener(new View.OnClickListener() { 8 @override 9 public void onClick(View v) { 10 //balabalabala... 11 } 12 }); 13 button3.setOnclickListener(new View.OnClickListener() { 14 @override 15 public void onClick(View v) { 16 //balabalabala... 17 } 18 });
public MyAdapter () { myListener = new View.OnClickListener() { @override public void onClick(View v) { v.getTag() v.getId() //balabalabala... } }); }
<resources> <item type="id" name="tag_first"></item> <item type="id" name="tag_second"></item> </resources>
view.setTag(R.id.tag_first, obj1);
view.setTag(R.id.tag_second, obj2);
1 public View getView(.....) { 2 .... 3 v.setTag(key, getItem(position)); 4 .... 5 }
1 public void getView (View convertView ,final int position ....) { 2 if (convertView == null) { 3 View v = LayoutInflater.from(mContext).inflate(...); 4 v.setOnclickListener(new View.OnClickListener () { 5 @override 6 public void onClick(View v) { 7 getItem(position); 8 } 9 }); 10 } else { 11 12 } 13 }
标签:
原文地址:http://www.cnblogs.com/androidsuperman/p/4779932.html