Ari*_*MAZ 4 java android android-imageview
我的应用程序中有许多产品网格.当用户选择网格中的一个项目时,我将开始一个新的活动作为DIALOG框并显示项目的名称,数量和图像.但我无法动态发送图像源.
这是我的代码
gridView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,int position, long id) {
//Toast.makeText(getApplicationContext(),((TextView) v.findViewById(R.id.grid_item_label)).getText(), Toast.LENGTH_SHORT).show();
Intent item_intent = new Intent(MainActivity.this, Item.class);
item_intent.putExtra("name",((TextView) v.findViewById(R.id.grid_item_label)).getText());
item_intent.putExtra("quantity",((TextView) v.findViewById(R.id.grid_item_quantity)).getText());
//my problem is here***************************************************
ImageView my_image = findViewById(R.id.grid_item_image).getDrawable();
item_intent.putExtra("image",my_image.getXXXXX());
//*********************************************************************
MainActivity.this.startActivity(item_intent);
}
});
Run Code Online (Sandbox Code Playgroud)
我应该使用什么来从ImageView获取图像源?
Bal*_* IT 34
使用Bundle之类的
imageView.buildDrawingCache();
Bitmap image= imageView.getDrawingCache();
Bundle extras = new Bundle();
extras.putParcelable("imagebitmap", image);
intent.putExtras(extras);
startActivity(intent);
Bundle extras = getIntent().getExtras();
Bitmap bmp = (Bitmap) extras.getParcelable("imagebitmap");
image.setImageBitmap(bmp );
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
49900 次 |
| 最近记录: |