我正在将数组列表项 [x,y,z...] 发送到自定义适配器。我想在列表视图中显示项目。我可以使用 for loop(x,y,z...like).in side getview 方法打印所有项目我可以 pritem itemnames[possition] 意味着它不能打印数组列表...
i try this code
public class CustomAdapter extends BaseAdapter{
public static ArrayList<String> arr=new ArrayList<String>();
public Context Context;
private LayoutInflater inflater;
HashMap<String, String> map = new HashMap<String, String>();
public CustomAdapter(Context context, ArrayList<String> arr) {
Context=context;
//inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// imageLoader=new ImageLoader(activity);
inflater=LayoutInflater.from(context);
arr=arr;
for(int i=0;i<arr.size();i++)
{
arr.get(i);
}
}
public int getCount() {
// TODO Auto-generated method stub
return arr.size();
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View vi=convertView;
vi=inflater.inflate(R.layout.selecteditemlistview, null);
System.out.println(arr.get(position));
TextView text=(TextView)vi.findViewById(R.id.selectedtext);
text.setText(arr.get(position));
return vi;
}
}
我在哪里做错了请告诉我...