我想将一个活动类中的位置值传递给另一个......
我的代码如下:
protected void onListItemClick(ListView listView, View v, int position,
long id) {
switch (position) {
case 1:
Intent newActivity1 = new Intent(this, BucketItemActivity.class);
newActivity1.putExtra("bucketno", position);
startActivity(newActivity1);
break;
case 2:
Intent newActivity2 = new Intent(this, BucketItemActivity.class);
newActivity2.putExtra("bucketno", position);
startActivity(newActivity2);
break;
}
}
将接收它的活动类..
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bucket_item);
String value = getIntent().getExtras().getString("bucketno");
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(value);
setContentView(textView);
}
但我总是在字符串值中得到一个空值......
请帮忙。