public void onListItemClick(ListView parent, View v, int position, long id)
{
super.onListItemClick(parent, v, position, id);
LayoutInflater inflater = (LayoutInflater)
this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final PopupWindow pw = new PopupWindow(
inflater.inflate(R.layout.offer_popup, null, false),
500,
600,
true);
pw.showAtLocation(this.findViewById(android.R.id.list), Gravity.CENTER, 0, 0);
ImageView closeimage=(ImageView) findViewById(R.id.imageView2);
closeimage.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
pw.dismiss();
}
});
offer_popup.xml辭退彈出當點擊一個圖像
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:theme="@android:style/Theme.Dialog"
android:orientation="vertical" android:weightSum="1">
<RelativeLayout android:layout_width="fill_parent"
android:id="@+id/relativeLayout_popup"
android:layout_height="wrap_content" android:layout_weight="0.65">
<ImageView android:layout_width="wrap_content"
android:src="@drawable/node_largeview_black"
android:layout_height="wrap_content"
android:id="@+id/imageView1"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="61dp"></ImageView>
<ImageView android:id="@+id/imageView2"
android:layout_height="wrap_content"
android:src="@drawable/close_button"
android:layout_width="wrap_content"
android:layout_alignTop="@+id/imageView1"
android:layout_alignRight="@+id/imageView1"></ImageView>
</RelativeLayout>
</LinearLayout>
我有一個列表視圖,如果我點擊條款行之一,彈出創建將使用offer_popup.xml,這裏面XML,有一個imageView2 ID是一個密切的圖像,並點擊它,彈出框將被解散。
但是,程序崩潰closeimage = null。
好了,現在也沒有崩潰,但是,我點擊closeimage,在彈出的圖像沒有得到關閉。 – lilzz 2012-01-10 16:44:35