我有这个代码的问题:
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = getLayoutInflater();
View row = inflater.inflate(R.layout.row, parent, false);
TextView textview = (TextView) row.findViewById(R.id.tvTop);
ImageView imageview = (ImageView) row.findViewById(R.id.list_image);
textview.setText(data_topText[position]);
imageview.setImageResource(data_image[position]);
row.setOnClickListener(new OnClickListener() {
public void onClick(View row) {
TextView textview = (TextView) row.findViewById(R.id.tvTop);
ImageView imageview = (ImageView) row.findViewById(R.id.list_image);
String product = textview.getText().toString();
int images = imageview.getId();
Intent i = new Intent(getApplicationContext(),
SecondScreenActivity.class);
i.putExtra("name", product);
i.putExtra("zurag", images);
startActivity(i);
won的传递图像另一个活动。SecondScreenActivity.java:
TextView txtName = (TextView) findViewById(R.id.txtName);
ImageView images = (ImageView) findViewById(R.id.image);
Intent intent = getIntent();
String name = intent.getStringExtra("name");
int pic =intent.getIntExtra("zurag", 0);
txtName.setText(name);
images.setImageResource(pic);
}