As shown above, when I click on more will pop up a PopupWindow, but always being given the wrong information is as follows:
05-02 03:13:22.999: E / AndroidRuntime (1404): FATAL EXCEPTION: main
05-02 03:13:22.999: E / AndroidRuntime (1404): java.lang.IllegalStateException: The specified child already has a parent You must call removeView () on the child's parent first
..05-02 03:13:22.999: E / AndroidRuntime (1404): at android.view.ViewGroup.addViewInner (ViewGroup.java: 1970)
05-02 03:13:22.999: E / AndroidRuntime (1404): at android.view.ViewGroup.addView (ViewGroup.java: 1865)
05-02 03:13:22.999: E / AndroidRuntime (1404): at android.view.ViewGroup.addView (ViewGroup.java: 1845)
05-02 03:13:22.999: E / AndroidRuntime (1404): at android.widget.PopupWindow.preparePopup (PopupWindow.java: 808)
05-02 03:13:22.999: E / AndroidRuntime (1404): at android.widget.PopupWindow.showAtLocation (PopupWindow.java: 681)
05-02 03:13:22.999: E / AndroidRuntime (1404): at com.shuangchi.activity.MainActivity.openPopupWindow (MainActivity.java: 209)
05-02 03:13:22.999: E / AndroidRuntime (1404): at com.shuangchi.activity.MainActivity.access $ 1 (MainActivity.java: 207)
05-02 03:13:22.999: E / AndroidRuntime (1404): at com.shuangchi.activity.MainActivity $ 1.onClick (MainActivity.java: 88)
05-02 03:13:22.999: E / AndroidRuntime (1404): at android.view.View.performClick (View.java: 2408)
05-02 03:13:22.999: E / AndroidRuntime (1404): at android.view.View $ PerformClick.run (View.java: 8816)
05-02 03:13:22.999: E / AndroidRuntime (1404): at android.os.Handler.handleCallback (Handler.java: 587)
05-02 03:13:22.999: E / AndroidRuntime (1404): at android.os.Handler.dispatchMessage (Handler.java: 92)
05-02 03:13:22.999: E / AndroidRuntime (1404): at android.os.Looper.loop (Looper.java: 123)
05-02 03:13:22.999: E / AndroidRuntime (1404): at android.app.ActivityThread.main (ActivityThread.java: 4627)
05-02 03:13:22.999: E / AndroidRuntime (1404): at java.lang.reflect.Method.invokeNative (Native Method)
05-02 03:13:22.999: E / AndroidRuntime (1404): at java.lang.reflect.Method.invoke (Method.java: 521)
05-02 03:13:22.999: E / AndroidRuntime (1404): at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java: 868)
05-02 03:13:22.999: E / AndroidRuntime (1404): at com.android.internal.os.ZygoteInit.main (ZygoteInit.java: 626)
05-02 03:13:22.999: E / AndroidRuntime (1404): at dalvik.system.NativeStart.main (Native Method)
Code is as follows:
private void init ()
{
/ / Squared adapter
adapter = new GridViewAdapter (this, titles, imgIds);
/ / Initialize the GridView
View view = LayoutInflater.from (MainActivity.this) inflate (R.layout.activity_morefunction, null);.
gridView = (GridView) view.findViewById (R.id.gridview);
gridView.setAdapter (adapter);
/ / Initialize PopupWindow
popupWindow = new PopupWindow (gridView, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, true);
popupWindow.setBackgroundDrawable (new BitmapDrawable ());
}
private void event ()
{
tabWidget.getChildAt (4). setOnClickListener (new View.OnClickListener ()
{
@ Override
public void onClick (View v)
{
parent = MainActivity.this.findViewById (android.R.id.tabhost);
openPopupWindow ();
}
});
}
/ ***
* Display PopupWindow
* /
private void openPopupWindow ()
{
popupWindow.showAtLocation (parent, Gravity.CENTER, 0,0);
}
Solving ah! How can display properly, Jiji Ji!<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Come to that! Come on people
Reply:
Their top yourself!
Reply:
Tips for your parenta obviously have other questions you can change the layout of the place, add the following to your PopupWindow try
Reply:
parent I know there are problems, I hope the effect is displayed on the TabHost PopupWindow
Reply:

Reply:
viewgroup first removeallchilds, then add the child on it. Error is that the child has a parent, the parent will give him an error.
Reply:
popupWindow = new PopupWindow (view, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, true);
popupWindow.setBackgroundDrawable (new BitmapDrawable ());
Reply:
Why do you initialize PopupWindow with GridView
Reply:
I want to show GridView in PopupWindow, ah!
Reply:
With seeking

Reply:
Object before displaying popUpWindowif (contentView! = null && contentView.getParent ()! = null) {
. ((ViewGroup) contentView.getParent ()) removeAllViews ();
}
No comments:
Post a Comment