listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
DataModel dataModel = (DataModel) parent.getItemAtPosition(position);
// Log.d("imageId--- ", String.valueOf(dataModel.getImageid()));
//
// Intent intent = new Intent(MainActivity.this, DetailActivity.class);
// intent.putExtra(IntentKeyConstant.INTENT_KEY_ITEM_DRAWABLE_ID, dataModel.getImageid());
// intent.putExtra(IntentKeyConstant.INTENT_KEY_ITEM_NAME, dataModel.getName());
// intent.putExtra(IntentKeyConstant.INTENT_KEY_ITEM_COST, dataModel.getPrice());
// intent.putExtra(IntentKeyConstant.INTENT_KEY_ITEM_NAME_DETAIL, dataModel.getDetailName());
// intent.putExtra(IntentKeyConstant.INTENT_KEY_ITEM_DETAIL, dataModel.getDetail());
Intent intent1 = new Intent(MainActivity.this, DetailActivity.class);
intent1.putExtra("keyclassobject",dataModel);
startActivity(intent1);
}
});
another activity is
final DataModel dataModel = (DataModel) intent.getSerializableExtra("keyclass");
// drawableId = intent.getIntExtra(IntentKeyConstant.INTENT_KEY_ITEM_DRAWABLE_ID, 0);
// String itemName = intent.getStringExtra(IntentKeyConstant.INTENT_KEY_ITEM_NAME);
// String itemCost = intent.getStringExtra(IntentKeyConstant.INTENT_KEY_ITEM_COST);
// String itemNameDetail = intent.getStringExtra(IntentKeyConstant.INTENT_KEY_ITEM_NAME_DETAIL);
// String itemDetail = intent.getStringExtra(IntentKeyConstant.INTENT_KEY_ITEM_DETAIL);
//Log.d("name", itemName);
// Log.d("itemcost",itemCost);
//Log.d("imageId ",String.valueOf(drawableId)+ "-"+Integer.parseInt(drawableId));
Typeface typeface=Typeface.createFromAsset(getAssets(),"fonts/fontawesome-webfont.ttf");
tv_item_rupee_symbol=(TextView)findViewById(R.id.tv_item_rupee_symbol);
tv_item_rupee_symbol.setTypeface(typeface);
toolbar_title.setText(dataModel.getName());
iv_item.setImageResource(dataModel.getImageid());
tv_item_name_detail.setText(dataModel.getDetailName());
tv_item_rupee_symbol.setText("\uf156");
tv_item_cost.setText(dataModel.getPrice());
tv_item_detail.setText(dataModel.getDetail());
答案 0 :(得分:0)
Intent intent = getIntent();
如果您的额外数据表示为字符串,则可以使用intent.getStringExtra(String name)
方法。在你的情况下:
String id = intent.getStringExtra("keyclassobject");