想在gridview显示图片,但就是不行
protectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);se...
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GridView gv=(GridView)findViewById(R.id.gridView1);
HashMap<String,Object> c_map=new HashMap<String, Object>();
int id=R.drawable.am;
Bitmap bm=BitmapFactory.decodeResource(getResources(),id);
Drawable dr=getResources().getDrawable(id);
Integer it=new Integer(id);
c_map.put("id",dr);
al.add(c_map);
SimpleAdapter sa=new SimpleAdapter(this, al, R.layout.activity_g,new String[]{"id"},new int[]{R.id.iv_h});
gv.setAdapter(sa);
Log.v("a","aaa");
}
Drawable和Bitmap和id甚至id变成integer都试过了,但就是不行c_map.put("id",?);的问号应该用什么。
谢谢!!! 展开
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GridView gv=(GridView)findViewById(R.id.gridView1);
HashMap<String,Object> c_map=new HashMap<String, Object>();
int id=R.drawable.am;
Bitmap bm=BitmapFactory.decodeResource(getResources(),id);
Drawable dr=getResources().getDrawable(id);
Integer it=new Integer(id);
c_map.put("id",dr);
al.add(c_map);
SimpleAdapter sa=new SimpleAdapter(this, al, R.layout.activity_g,new String[]{"id"},new int[]{R.id.iv_h});
gv.setAdapter(sa);
Log.v("a","aaa");
}
Drawable和Bitmap和id甚至id变成integer都试过了,但就是不行c_map.put("id",?);的问号应该用什么。
谢谢!!! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询