我不能在popupwindow裏面過濾列表視圖。android-在popupwindow裏面過濾listview
它失敗,異常
android.view.WindowManager$BadTokenException: Unable to add window -- token [email protected] is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:679)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
at android.widget.PopupWindow.invokePopup(PopupWindow.java:1378)
at android.widget.PopupWindow.showAtLocation(PopupWindow.java:1154)
at android.widget.PopupWindow.showAtLocation(PopupWindow.java:1121)
at android.widget.AbsListView.positionPopup(AbsListView.java:5665)
at android.widget.AbsListView.showPopup(AbsListView.java:5651)
at android.widget.AbsListView.onTextChanged(AbsListView.java:6095)
at android.widget.TextView.sendOnTextChanged(TextView.java:8187)
at android.widget.TextView.setText(TextView.java:4483)
at android.widget.TextView.setText(TextView.java:4337)
at android.widget.EditText.setText(EditText.java:89)
at android.widget.TextView.setText(TextView.java:4312)
at android.widget.AbsListView.setFilterText(AbsListView.java:1944)
我顯示PopupWindow爲:
popupWindow.showAtLocation(getWindow().getDecorView(), Gravity.CENTER, 0, 0);
彈出佈局是
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:hint="" />
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</RelativeLayout>
你能提供指針?
提供適用於listview的適配器代碼? –
我解決了這個問題,通過使用對話框而不是popupwindow – GJain