Reputation: 1
Why in below code Course is not transmitted ?
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);
}
});
Code in second activity:
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
Please help Please help Please help
Upvotes: 0
Views: 2719
Reputation: 6350
Passing from one activity to other
Intent intent = new Intent(activity1.this, activity2.class);
intent.putExtra("message", message);
startActivity(intent);
In second activity oncreate
Bundle bundle = getIntent().getExtras();
String message = bundle.getString("message");
or
Intent intent = getIntent();
String get_value = intent.getStringExtra("key");
Change
intent.putExtra(".Course",courses1.get(position));
by this
intent.putExtra(".Course",courses1.get(position).getCourseName())
Upvotes: 1