要创建一个简单的工作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