http://freestyle21.cn
双击,弹出popwindow,里面是一个自定义布局,只有一个imageview。
问题是
View contentView = LayoutInflater.from(con).inflate(R.layout.popup, null);
// 设置popupWindow的背景颜色
contentView.setBackgroundColor(Color.GREEN);
View view1=View.inflate(con,R.layout.main,null);
View view2=View.inflate(con,R.layout.popup,null);
ImageView iview=(ImageView)view1.findViewById(R.id.view);
Log.i("===","iview:"+iview);
iview.setBackgroundColor(Color.RED);
Bitmap bmp=BitmapFactory.decodeResource(getResources(),R.drawable.a);
Log.i("===","bmp:"+bmp);
iview.setImageBitmap(bmp);
总不能显示图片,bmp里面也有东西,一直想,找了人帮忙,都没办法。。
冷静了一下,想想这应该很简单,以前的都可以,现在为什么不可以呢,到底是哪里不同呢?
想了一下,以前是直接findViewbyid(R.id.**),现在那个imageview不在默认的layout里面,我是通过
View view2=View.inflate(con,R.layout.popup,null);
ImageView iview=(ImageView)view1.findViewById(R.id.view);
来做了,有什么问题呢?
仔细看下代码,第一行的是什么东西,不就是我刚才的
View view2=View.inflate(con,R.layout.popup,null);么?于是尝试着把<pre name="code" class="java" style="background-color: rgb(255, 255, 255); ">View view2=View.inflate(con,R.layout.popup,null);删掉,搞定。
想想和以前哪里不一样了。