WEB开发网
开发学院手机开发Android 开发 Android ListView复杂多功能详解 阅读

Android ListView复杂多功能详解

 2012-09-18 09:28:02 来源:WEB开发网   
核心提示:for (int i = 0; i < items.length; i++) {Map<String, Object> item = new HashMap<String, Object>();item.put("right1",R.drawable.icon2);it


for (int i = 0; i < items.length; i++) {
Map<String, Object> item = new HashMap<String, Object>();
item.put("right1",
R.drawable.icon2);
item.put("text", items[i]);
item.put("right",
R.drawable.icon1);


results.add(item);
}


return results;


}


@Override
public boolean onCreateOptionsMenu(
Menu menu) {
getMenuInflater().inflate(
R.menu.activity_main,
menu);
return true;
}
}







---------------------------------------------.ImageAdapter


package com.example.tezt;


import java.util.List;
import java.util.Map;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;


public class ImageAdapter extends
BaseAdapter {
private List<Map<String, Object>> datas;


private Context context;


public ImageAdapter(
Context context,
List<Map<String, Object>> datas) {
this.context = context;
this.datas = datas;
}


@Override
public int getCount() {
// TODO Auto-generated method stub
return this.datas.size();
}


@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return this.datas.get(position);
}


@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}


@Override
public View getView(int position,
View convertView,
ViewGroup parent) {
// TODO Auto-generated method stub
ViewHolder holder = null;


if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater
.from(context)
.inflate(
R.layout.list_item,
null);
holder.itemRightImage1 = (ImageView) convertView
.findViewById(R.id.item_right1);
holder.itemText = (TextView) convertView
.findViewById(R.id.item_text);
holder.itemRightImage = (ImageView) convertView
.findViewById(R.id.item_right);


convertView.setTag(holder);
}

上一页  1 2 3 4  下一页

Tags:Android ListView 复杂

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接