我是android新手,想要查看单项,我已成功创建JSON项目列表。
这是适配器
public class ListViewAdapter extends BaseAdapter {
Context context;
LayoutInflater inflater;
ArrayList<HashMap<String, String>> data;
ImageLoader imageLoader;
HashMap<String, String> resultp = new HashMap<String, String>();
public ListViewAdapter(Context context,
ArrayList<HashMap<String, String>> arraylist) {
this.context = context;
data = arraylist;
imageLoader = new ImageLoader(context);
}
public int getCount() {
return data.size();
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
public View getView(final int position, View convertView, ViewGroup parent) {
TextView country;
ImageView flag;
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.listview_item, parent, false);
resultp = data.get(position);
country = (TextView) itemView.findViewById(R.id.country);
flag = (ImageView) itemView.findViewById(R.id.flag);
country.setText(resultp.get(PhotosActivity.COUNTRY));
imageLoader.DisplayImage(resultp.get(PhotosActivity.FLAG), flag);
itemView.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
resultp = data.get(position);
Intent intent = new Intent(context, SingleItemView.class);
intent.putExtra("country", resultp.get(PhotosActivity.COUNTRY));
intent.putExtra("flag", resultp.get(PhotosActivity.FLAG));
context.startActivity(intent);
}
});
return itemView;
}
}