PopupWindow doesn't show up

by jotobjects » Tue, 26 Apr 2011 03:36:25 GMT


Sponsored Links
 I have the following code but the PopupWindow does not appear.  I want
it to appear in the center of the screen. I'm not clear about what
"parent" in the last line is supposed to be... Does anybody see what
is wrong here?

PopupWindow popup = new PopupWindow(context);
TextView contentView = new TextView(context);
popup.setContentView(contentView);
contentView.setLayoutParams(
    new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
contentView.setText(text);
popup.showAtLocation(parent, Gravity.CENTER, 0, 0);

-- 



Re: PopupWindow doesn't show up

by TreKing » Tue, 26 Apr 2011 04:53:31 GMT


 



How is this compiling?

-------------------------------------------------------------------------------------------------
TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices

-- 


Sponsored Links


Re: PopupWindow doesn't show up

by jotobjects » Tue, 26 Apr 2011 07:27:19 GMT


 



context == activity.  text=="foobar and merry christmas".
I've tried a couple of different things for parent.  Here is the full
method -

public void onClick(View v)
{
        PopupWindow popup = new PopupWindow(context);
        TextView contentView = new TextView(context);
        popup.setContentView(contentView);
        contentView.setLayoutParams(
                new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
        contentView.setText(text);
        //View window = ((Activity)context).getWindow().getDecorView();
        popup.showAtLocation(v, Gravity.CENTER, 0, 0);
}

It does compile and tracing it with the debugger it executes without
error.

-- 



Re: Re: PopupWindow doesn't show up

by TreKing » Tue, 26 Apr 2011 07:58:42 GMT


 



OK, I thought you literally didn't know what you variable "parent" was,
which didn't make much sense :-P

Well, I've not used PopupWindow myself, so I don't know what to tell you.
FWIW, I tried an equally simple example (threw a textview with "Hello" in it
into a POW and tried to show it at the location of a ImageView I have in a
listview) and it did not work either.

Also tried showAsDropDown() and that didn't work either. I've seen the thing
used in plenty of other apps so I'm sure it works, but I guess it's not
as straightforward to use as it would appear.

-------------------------------------------------------------------------------------------------
TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices

-- 



Other Threads

1. is the order value of Menu.CATEGORY_SECONDARY a property of the menu item or the group?

For example

menu.add(0                                                     //Group
        ,1                                                           //
item id
        ,Menu.CATEGORY_SECONDARY           //Order
        ,"item1");                                                //
menu item name

This seem to suggest that the "secondary" belongs to the "item" and
not the group. However in describing menus through XML

    <group android:id="@+id/least_used_items"
        android:menuCategory="secondary">

        <item android:id="@+id/last_least_item"
            android:orderInCategory="3"
            android:title="@string/last_least_often" />

        <item android:id="@+id/middle_least_item"
            android:orderInCategory="2"
            android:title="@string/middle_least_often" />

        <item android:id="@+id/first_least_item"
            android:orderInCategory="0"
            android:title="@string/first_least_often" />

The "secondary" seem to be assigned to the "group".

Can I have a group, then, that has one "item" that is a
"CATEGORY_SECONDARY" and one item that is a "CATEGORY_ALTERNATIVE"?

If you have read this far, do you know where the menu.xml files may
have been described at some length.

Thanks
Satya
--~--~---------~--~----~------------~-------~--~----~

2. Developers Count on Android v's iPhone?

Anyone out there that can tell us the count of developer-members for
iPhone?  Is this info available from any of you iphone developers?

On Android its :

3. Starting an instrumentation with an intent

4. How & When we use "KeyguardLock" or "KeyguardManager"

5. Activities Refactoring

6. Keyboard confusion

7. I want to know a button's width before it is drawn on the screen! possible?