封装的适配器adapter如何用,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
创新互联-云计算及IDC服务提供商,涵盖公有云、IDC机房租用、服务器托管、等保安全、私有云建设等企业级互联网基础服务,联系电话:028-86922220
//封装的适配器类 adapter
public class NewJobAdapter extends BaseAdapter{
private List
//activity调用
public class NewJobActivity extends Activity implements OnItemClickListener{
private List> data = null;
private List> list;
private ListView mListView;
private NewJobAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_new_job);
mListView = (ListView) findViewById(R.id.new_job_list);
mListView.setOnItemClickListener(this);
data = getData();// 获取数据
adapter = new NewJobAdapter(this, data);
mListView.setAdapter(adapter);
}
private List> getData(){
list = new ArrayList>();
Map map;
for(int i=0; i<20; i++){
map = new HashMap();
map.put("time", "2015-01-30");
map.put("img", R.drawable.ic_launcher);
map.put("area", "三亚市区");
map.put("position", "促销员");
list.add(map);
}
return list;
}
public void backClick(View v){
NewJobActivity.this.finish();
}
@Override
public void onItemClick(AdapterView> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
//Toast.makeText(this, "" + arg2, Toast.LENGTH_LONG).show();
}
}
//item_list
关于封装的适配器adapter如何用问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注创新互联行业资讯频道了解更多相关知识。
网页题目:封装的适配器adapter如何用
URL网址:
http://cdxtjz.com/article/gchsjs.html