这是Main_Activity
Integer[] imgid = {R.drawable.frame3,R.drawable.frame3,R.drawable.frame3,R.drawable.frame3,
R.drawable.frame5,R.drawable.frame6,R.drawable.frame7,R.drawable.frame8,
R.drawable.frame9,};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_image_activity);
Bundle extras = getIntent().getExtras();
byte[] byteArray = extras.getByteArray("image");
Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
img_img=(ImageView)findViewById(R.id.img);
img_img.setImageBitmap(bmp);
Adapter adapter=new Adapter(this,imgid);
list=(ListView)findViewById(R.id.listview);
list.setAdapter(adapter);
Log.e("Your in Main","Welcome_______");
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String pos=Integer.toString(position);
Toast.makeText(EditImageActivity.this, "Your Position is"+pos, Toast.LENGTH_SHORT).show();
}
});
}
}
这是Adapter类___________
public class Adapter extends ArrayAdapter<String> {
private final Activity context;
private final Integer[] images;
public Adapter(Activity context, Integer[] imgid) {
super(context, R.layout.list_image);
this.context=context;
this.images=imgid;
}
@Override
public View getView(int position,View convertView,ViewGroup parent) {
Log.e("Your in getView","Welcome");
LayoutInflater inflater=context.getLayoutInflater();
View rowView=inflater.inflate(R.layout.list_image, null,true);
ImageView imageView = (ImageView) rowView.findViewById(R.id.list_img);
imageView.setImageResource(images[position]);
return rowView;
}
}
答案 0 :(得分:0)
更新
View rowView=inflater.inflate(R.layout.list_image, null,true);
与
View rowView=inflater.inflate(R.layout.list_image, null);