我正在创建一个哈希图并将其传递给另一个活动这是我的代码
bt6.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(gkwebbrowserActivity.this, Icons.class);
intent.putExtra("hashmap", orderMap);
try {
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
});
在我的第二个活动中,我正在创建一组图像按钮并设置存储在 hashmap 中的图像位图这里是第二个活动的代码
public class Icons extends Activity {
GridLayout gl;
ImageButton imb1;
HashMap<Integer, Bitmap> ordermap;
int i;
/* (non-Javadoc)
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.icon);
try {
ordermap= new HashMap<Integer, Bitmap>();
ordermap = (HashMap<Integer, Bitmap>) getIntent().getSerializableExtra("hashmap");
} catch (ClassCastException e) {
e.printStackTrace();
}
gl=(GridLayout)findViewById(R.id.layout);
i=ordermap.size();
gl.setUseDefaultMargins(true);
gl.setColumnCount(2);
gl.setRowCount(i/2);
Iterator entries = ordermap.entrySet().iterator();
while (entries.hasNext()) {
Entry thisEntry = (Entry) entries.next();
imb1 = new ImageButton(this);
imb1.setImageBitmap((Bitmap)thisEntry.getValue());
gl.addView(imb1);
}
}
}
但是第二个活动没有开始,第一个活动在调用第二个活动后崩溃。我将位图存储在哈希图中,之后我调用了第二个活动。谁能告诉我问题是什么以及如何删除它这是 logcat
D/dalvikvm(925): GC_CONCURRENT freed 429K, 8% free 10618K/11463K, paused 8ms+4ms
D/Capturing screenshot of webview(925): First screenshot
D/dalvikvm(925): GC_FOR_ALLOC freed 4K, 8% free 10614K/11463K, paused 76ms
I/dalvikvm-heap(925): Grow heap (frag case) to 11.249MB for 855616-byte allocation
D/dalvikvm(925): GC_CONCURRENT freed <1K, 8% free 11450K/12359K, paused 4ms+11ms
W/EGL_emulation(925): eglSurfaceAttrib not implemented
E/JavaBinder(925): !!! FAILED BINDER TRANSACTION !!!