Sorry, haven't been here in a while....

This is how you can do it in a nutshell, ugly and all in java :)

        LayoutParams wrapParams = new
LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

        final LinearLayout contentView = new LinearLayout(this);
        contentView.setLayoutParams(new
LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        contentView.setOrientation(LinearLayout.VERTICAL);
        contentView.setGravity(Gravity.CENTER);
        setContentView(contentView);

        final TextView popupContent = new TextView(this);
        popupContent.setLayoutParams(wrapParams);
        popupContent.setText("Replace this TextView with your
layout");

        // this is the only important part
        final PopupWindow popupWindow = new PopupWindow(this, null,
android.R.style.Widget_PopupWindow);
 
popupWindow.setWindowLayoutMode(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
        // set according to your needs
 
popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
        // set according to your needs
        popupWindow.setOutsideTouchable(false);
        popupWindow.setContentView(popupContent);
        // this is the only important part

        final Button button = new Button(this);
        button.setLayoutParams(wrapParams);
        button.setText("Click Me");
        contentView.addView(button);

        button.setOnClickListener(
                new OnClickListener() {
                        @Override public void onClick(View v) {
                               popupWindow.showAsDropDown(v);
                                }
                        }
        );
        popupContent.setOnClickListener(
                new OnClickListener() {
                        @Override public void onClick(View v) {
                                popupWindow.dismiss();
                        }
                }
        );



On May 27, 1:23 am, ionel <[email protected]> wrote:
> Can you put some code how you created PopupWindows?
>
> On May 21, 10:53 pm, Nerdrow <[email protected]> wrote:
>
>
>
> > I used the layouts, graphics, and animation from the default Contacts
> > app, which uses separate layouts for the header, body, and footer, but
> > you can merge them all into one.  Create a PopupWindow, set that
> > layout as the contentView, then use showAsDropDown(View anchor, int
> > xoff, int yoff) to show it.  The Contacts layout has a LinearLayout
> > inside a HorizontalScrollView w/ImageViews for the two grips, so just
> > stick your content in the LinearLayout between the grips and you're
> > set.  The QuickContactWindow class has a method to set the arrows and
> > everything, copy & paste.
>
> > On May 12, 7:58 pm, Adam <[email protected]> wrote:
>
> > > Is there a way to get that same popup layout like they have on twitter
> > > or in the quick contacts popup? Do we just combine the top, middle,
> > > bottom image resources as backgrounds in some sort of layout, or is
> > > there a simpler way?
>
> > > On May 10, 5:16 pm, skink <[email protected]> wrote:
>
> > > > Mark Murphy wrote:
> > > > > westmeadboy wrote:
> > > > > > Anyone any ideas?
>
> > > > > Ummm...figure out where the item is positioned on screen, then use 
> > > > > some
> > > > > margin tricks to position theirpopupto match, I suppose.
>
> > > > if you usePopupWindowyou don't have to use margins at all - you can
> > > > position yourpopupin any (x,y) location
>
> > > > moreover: using showAsDropDown you don't even have to locate anchor
> > > > view position
>
> > > > pskink
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Android Developers" group.
> > > > To post to this group, send email to [email protected]
> > > > To unsubscribe from this group, send email to
> > > > [email protected]
> > > > For more options, visit this group 
> > > > athttp://groups.google.com/group/android-developers?hl=en
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/android-developers?hl=en
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group 
> > athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to