atom feed7 messages in com.googlegroups.android-developersRe: popupWindow doesn't pop up
FromSent OnAttachments
George PipkinFeb 2, 2008 9:02 am 
Romain GuyFeb 2, 2008 11:28 am 
George PipkinFeb 3, 2008 1:55 pm 
dm1973Feb 3, 2008 2:39 pm 
George PipkinFeb 3, 2008 3:03 pm 
George PipkinFeb 3, 2008 7:50 pm 
George PipkinFeb 4, 2008 7:43 am 
Subject:Re: popupWindow doesn't pop up
From:George Pipkin (gp.@virginia.edu)
Date:Feb 3, 2008 3:03:26 pm
List:com.googlegroups.android-developers

When you say the popup has a View that has a parent, are you refering to the fact that R.layout.relative_layout_2 is a complex layout that has three views contained within it ?

- George

On Feb 3, 5:39 pm, dm1973 <davi@gmail.com> wrote:

I am not sure that will work. I don't know if you can place Views that already have a parent in a popup. What has worked for me is putting up the view to show in the popup in it's own .xml file. Inflating that XML file. And then putting it in the popup. ViewInflate vf =(ViewInflate) mContext.getSystemService(Context.INFLATE_SERVICE); View cv = vf.inflate(R.layout.popupview, null, null); w = new PopupWindow(cv, 220, 300, false); w.show(button); w.update(button,220,300); button is view I want to base the popup off off.

On Feb 3, 1:55 pm, George Pipkin <gp.@virginia.edu> wrote:

Ok - well I tried putting it into an onKeyDown, and I verified that the method is actually being called, and that the popupWindow class is successfully being created with the specified dimentions. It just never shows up on my emulator. Here's what I'm trying now:

package com.google.android.samples.view;

import android.app.Activity; import android.os.Bundle; import android.view.KeyEvent; import android.widget.PopupWindow;

public class RelativeLayout1 extends Activity {

PopupWindow pw = null; public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.relative_layout_1); }

public boolean onKeyDown(int keyCode, KeyEvent event) { pw = new PopupWindow(this.findViewById(R.layout.relative_layout_2), 100,100,true); pw.show(this.findViewById(R.layout.relative_layout_1), 20, 20); pw.update(20,20,100,100); return true; }

}

On Feb 2, 2:29 pm, "Romain Guy" <roma@google.com> wrote:

Hi, You should probably not do this in the onCreate method. It might be suffering from the same issue as showing a Dialog from onCreate.

On Feb 2, 2008 9:03 AM, George Pipkin <gp.@virginia.edu> wrote:

Hi -

I tried to post this as a reply to another posting, and the system wouldn't accept it. I am trying to understand how to use the popupWindow, and I used some code from one of the examples as a starting place. I understood from looking through the docs that I had to give the thing as size, and that I had to call update after show. However, for some reason, it still doesn't show. Here is the code I am using:

public class RelativeLayout1 extends Activity {

PopupWindow pw = null; public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.relative_layout_1); pw = new PopupWindow(this.findViewById(R.layout.relative_layout_2), 100,100,true); pw.show(this.findViewById(R.id.view3), 20, 20); pw.update(20,20,100,100);

} }

relative_layout_1 and relativer_layout_2 are pretty similar: here's relative_layout_1:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/ android" android:layout_width="fill_parent" android:layout_height="fill_parent">

<!-- view1 goes on top --> <TextView id="@+id/view1" android:background="@drawable/red" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:text="@string/relative_layout_1_top"/>

<!-- view2 goes on the bottom --> <TextView id="@+id/view2" android:background="@drawable/green" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:text="@string/relative_layout_1_bottom"/>

<!-- view3 stretches betweeen view1 and view2 --> <TextView id="@+id/view3" android:background="@drawable/yellow" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_above="@id/view2" android:layout_below="@id/view1" android:text="@string/relative_layout_1_center"/>

</RelativeLayout>

What I'd like to see happen is the popupWindow pop up over view3.

- George Pipkin