码迷,mamicode.com
首页 > 其他好文 > 详细

简单的自定义Adapter

时间:2016-07-13 20:07:12      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:

 1 import android.content.Context;
 2 import android.view.LayoutInflater;
 3 import android.view.View;
 4 import android.view.ViewGroup;
 5 import android.widget.BaseAdapter;
 6 import android.widget.ImageView;
 7 import android.widget.TextView;
 8 import android.widget.Toast;
 9 
10 import com.example.administrator.yunphone.R;
11 import java.util.List;
12 
13 /**
14  * Created by Administrator on 2016/7/13.
15  */
16 public class PhoneNumAdapter extends BaseAdapter implements View.OnClickListener {
17     private List<String> mList;
18     private Context context;
19     private LayoutInflater layoutInflater;
20 
21     public PhoneNumAdapter(Context context, List phoneList){
22         this.context=context;
23         this.mList=phoneList;
24         layoutInflater=LayoutInflater.from(context);
25     }
26     @Override
27     public int getCount() {
28         return mList.size();
29     }
30 
31     @Override
32     public Object getItem(int i) {
33         return mList.get(i);
34     }
35 
36     @Override
37     public long getItemId(int i) {
38         return i;
39     }
40 
41     @Override
42     public View getView(int i, View view, ViewGroup viewGroup) {
43         View v;
44         if(view!=null){
45             v=view;
46         }else {
47             v=layoutInflater.inflate(R.layout.call_item,viewGroup,false);
48         }
49         TextView textView= (TextView) v.findViewById(R.id.item_view);
50         textView.setText(mList.get(i));
51         ImageView imageView= (ImageView) v.findViewById(R.id.item_down);
52         imageView.setOnClickListener(this);
53         return v;
54     }
55 
56     @Override
57     public void onClick(View view) {
58         Toast.makeText(context,"尚未完成",Toast.LENGTH_SHORT).show();
59     }
60 }

 

简单的自定义Adapter

标签:

原文地址:http://www.cnblogs.com/yoyohong/p/5667735.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!