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. How to place a call from an application

Hi:

I tried to place a call from my application, but it always crashes
after the following section of code:

    Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
Uri.fromParts(
        "tel", number, null));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);

(number is a type of string, where I put a valid phone number in)

When I step through with de{*filter*}, I got a "SecurityException" from
Parcel.readException(int, String) line: 1066

The exception reads:

Permission Denial: starting Intent
{ action=android.intent.action.CALL_PRIVILEGED data=tel:12
flags=0x10000000 comp={com.android.phone/
com.android.phone.PrivilegedOutgoingCallBroadcaster} } from
ProcessRecord{43679c98 6472:com.xyz.test/10029} (pid=6472, uid=10029)
requires android.permission.CALL_PRIVILEGED

However, I have already added this to my AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=" http://www.***.com/ ;
        package="com.xyz.test" android:versionCode="1"
        android:versionName="0.1.0">
        <uses-permission android:name="android.permission.CALL_PRIVILEGED" />
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.READ_CONTACTS" />
        <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    ...

This is the same way I added other permissions such as READ_CONTACTS,
where the permission was granted after I added it to the manifest
file.

Any suggestions? Is CALL_PRIVILEGED locked down somehow and can only
be accessed by apps from Google?

Mobi

--~--~---------~--~----~------------~-------~--~----~

2. Transparent textures in OpenGL

I'm currently attempting to make a game using OpenGL and all is well
in the emulator. I'm using PNGs with transparencies to create the
textures, and in the emulator, they show up as expected. But when I
run it on the G1, all transparent areas show up as black.

I've seen some reports that I need to change the texture from ARGB to
RGBA, but that made my image really small and gave me 4 of the same
image (like it separated each color of the texture into its own
image). I've also seen a suggestion to disable GL_LIGHTING, but that
didn't help either. Is there anything I can do to actually get
transparencies to show up as transparent on the G1?
--~--~---------~--~----~------------~-------~--~----~

3. Who know the WMA and WMV playback ?

4. Stack overflow - 32 deep class hierarchy

5. Layout support two items in a 'row' filling width?

6. Layout support two items in a 'row' filling width?

7. About building Single module