我正在尝试在MainActivity.java中获取位图格式imageview。图像位于Item.xml显示的卡片上,借助于数组适配器。 这是MainActivity.java
private ImageView mimage;
mimage = (ImageView) findViewById(R.id.image);
flingContainer.setOnItemClickListener(new SwipeFlingAdapterView.OnItemClickListener() {
@Override
public void onItemClicked(int itemPosition, Object dataObject) {
cards obj = (cards) dataObject;
String name = obj.getName();
String info = obj.getInfo();
BitmapDrawable drawable = (BitmapDrawable) mimage.getDrawable(); //this is line 117
final Bitmap bitmap = drawable.getBitmap();
Intent intent = new Intent(MainActivity.this, ProfileActivity.class);
intent.putExtra("Name",name);
intent.putExtra("Info",info);
intent.putExtra("bitmap",bitmap);
startActivity(intent);
finish();
return;
}
});
}
这是错误
`java.lang.NullPointerException: Attempt to invoke virtual method android.graphics.drawable.Drawable android.widget.ImageView.getDrawable()' on a null object reference``at com.example.android.tindercone.MainActivity$2.onItemClicked(MainActivity.java:117)`