我有这个代码的问题:
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);
赢得了传递图像的另一项活动。 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);
}
答案 0 :(得分:0)
你的第二项活动就是这样改变
TextView txtName = (TextView) findViewById(R.id.txtName);
ImageView images = (ImageView) findViewById(R.id.image);
Intent intent = getIntent();
String name = intent.getStringExtra("name");
int pic =getIntent().getExtras().getInt("zurag");
txtName.setText(name);
images.setBackgroundResource(pic);