我做了一个弹出窗口,工作正常,但我想写入TextView。尽管Eclipse找到了TextView的id并且没有显示任何问题,但使用标准方法并不行(只是崩溃了)。弹出窗口是另一个XML布局。在另一个布局上访问textview
生成
public PopupWindow pw;
public void popUpShow() {
LayoutInflater inflater = (LayoutInflater)
this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
pw = new PopupWindow(
inflater.inflate(R.layout.popup, null, false),
400,
600,
true);
pw.showAtLocation(this.findViewById(R.id.main), Gravity.CENTER, 0, 0);
}
布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/popup_layout"
android:orientation="vertical"
android:padding="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#AAA"
>
<TextView
android:id="@+id/popupOut"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text=""
/>
<Button
android:id="@+id/popupclose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/close"
android:onClick="popUpHide" />
</LinearLayout>
视图可以请你添加一些代码.. – user936414 2012-03-06 05:07:27