codes for filling the imageview onClick event on the main activity
if (view.equals(findViewById(R.id.madrid_imageButton))) {
Bitmap madridImage = BitmapFactory.decodeResource(getResources(),R.drawable.madrid);
Intent buyProduct_Intent = new Intent(MainActivity.this,MainActivityBuy.class);
buyProduct_Intent.putExtra("Flavor","madrid");
buyProduct_Intent.putExtra("Description",madrid_Description);
buyProduct_Intent.putExtra("Bitmap",madridImage);
startActivity(buyProduct_Intent);
} else if (view.equals(findViewById(R.id.berlin_imageButton))) {
Bitmap berlinImage = BitmapFactory.decodeResource(getResources(),R.drawable.berlin);
Intent buyProduct_Intent = new Intent(MainActivity.this,MainActivityBuy.class);
buyProduct_Intent.putExtra("Flavor","berlin");
buyProduct_Intent.putExtra("Description",berlin_Description);
buyProduct_Intent.putExtra("Bitmap",berlinImage);
startActivity(buyProduct_Intent);
I have 10 of the above checks and here is the code for the new Activity that passed after the above condition
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.buy_product); // Load buy product screen
TextView productNameTextView = (TextView) findViewById(R.id.productName_textView);
TextView productDesciptionTextView = (TextView) findViewById(R.id.productDescription_textView);
ImageView productImageView = (ImageView) findViewById(R.id.productImage_imageView);
Bundle extras = getIntent().getExtras();
if (extras != null) {
productNameTextView.setText(extras.getString("Flavor"));
productDesciptionTextView.setText((extras.getString("Description")));
Bitmap sharmImage = (Bitmap)this.getIntent().getParcelableExtra("Bitmap");
productImageView.setImageBitmap(sharmImage);
}
findViewById(R.id.size_radioButton_60ml).performClick();
findViewById(R.id.nic_radioButton_3mg).performClick();
findViewById(R.id.size_radioButton_30ml).performClick();
};
from this 2nd activity I need to intent a third activity that uses some of the views values. I successed to retreive all the needed values except for the imageView it displays as empty don't know why .....
here is the code that intents the third activity that contains the issue
public void onClickAddToCart(View view) {
TextView orderDetailsTextView1 = (TextView) findViewById(R.id.productName_textView);
TextView orderDetailsTextView2 = (TextView) findViewById(R.id.totalItems_textView);
TextView orderDetailsTextView3 = (TextView) findViewById(R.id.totalCost_textView);
String orderDetailsTextView = orderDetailsTextView1.getText().toString() + " " + orderDetailsTextView2.getText().toString() + " " + orderDetailsTextView3.getText().toString();
ImageView productImageView = (ImageView) findViewById(R.id.productImage_imageView);
ImageView newImageView = new ImageView(this);
newImageView.setImageDrawable(productImageView.getDrawable());
int drawableId = getResources().getIdentifier(productImageView.getDrawable().toString(), "drawable", getPackageName());
Bitmap productImage = BitmapFactory.decodeResource(getResources(),drawableId);
Intent buyProduct_Intent = new Intent(MainActivityBuy.this, Cart.class);
buyProduct_Intent.putExtra("OrderDetails", orderDetailsTextView);
buyProduct_Intent.putExtra("Bitmap", newImageView.getDrawable().toString());
startActivity(buyProduct_Intent);
}
below are the codes of the onCreate of the third activity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.product_cart); // Load the cart XML Screen
TextView orderDetailsTextView = (TextView) findViewById(R.id.orderDetailsTextView);
ImageView productImageView = (ImageView) findViewById(R.id.productImage_imageView);
Bundle extras = getIntent().getExtras();
if (extras != null) {
orderDetailsTextView.setText(extras.getString("OrderDetails"));
Bitmap productImage = (Bitmap)this.getIntent().getParcelableExtra("Bitmap");
productImageView.setImageBitmap(productImage);
}
}
@Override
public void onBackPressed() {
// startActivity(new Intent(MainActivityBuy.this, MainActivity.class));
finish();
}
}
By the way there is no errors or crashes .. only blank imageview at the third activity but the 1st two activities are functioning correctly and the XMLs are fine as well ..