为什么在下面的代码课程没有传输?
final List<Course> courses1 = db.findFiltered(String.format("day == %d ", 0),"startTime ASC");
final ListView lv1 = (ListView) findViewById (R.id.sat);
registerForContextMenu(lv1);
lv1.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Auto-generated method stub
Intent intent=new Intent(MainActivity.this, ShowDetailActivity.class);
Log.i("tagID",courses1.get(position).getCourseName());
//displayed in LogCat
intent.putExtra(".Course",courses1.get(position));
startActivity(intent);
}
});
第二项活动中的代码:
course = (Course) getIntent().getExtras().get(".Course");
//or
/*Bundle b = getIntent().getExtras();
course = b.getParcelable(".Course");*/
Log.i("tagID",course.getCourseName());
//is not displayed in LogCat
请帮助请帮忙请帮忙
答案 0 :(得分:1)
从一项活动转到其他活动
Intent intent = new Intent(activity1.this, activity2.class);
intent.putExtra("message", message);
startActivity(intent);
第二项活动oncreate
Bundle bundle = getIntent().getExtras();
String message = bundle.getString("message");
或
Intent intent = getIntent();
String get_value = intent.getStringExtra("key");
更改
intent.putExtra(".Course",courses1.get(position));
由此
intent.putExtra(".Course",courses1.get(position).getCourseName())