要創建一個簡單的工作PopupWindow,我們需要做到以下幾點:PopupWindow android系統
popup_example.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:padding="10dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="Test Pop-Up" />
</LinearLayout>
Java代碼
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
PopupWindow pw = new PopupWindow(inflater.inflate(R.layout.popup_example, null, false),100,100, true);
pw.showAtLocation(this.findViewById(R.id.main), Gravity.CENTER, 0, 0);
我的要求是我需要一個
<TEXTVIEW android:layout_height="wrap_content" android:layout_width="fill_parent" />
和
<BUTTON android:id="@+id/end_data_send_button" android:text="Cancel"/>
我
popup_example.xml
。我如何在Java代碼中處理這兩個組件?
根據您展示什麼,這大概應該是對話,而不是一個PopupWindow。 – 2012-02-22 12:17:30
...現在比以往任何時候都更多的是DialogFragments可用http://developer.android.com/guide/topics/ui/dialogs.html – samosaris 2012-12-03 14:00:16
嘿,我可以使用彈出窗口來顯示放大的圖像(上點擊圖片),這是動態顯示在列表視圖中?謝謝。 – 2015-04-22 17:14:22