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);刪掉,搞定。
想想和以前哪裏不一樣了。