How to create a popupWindow

Put your problem here if it does not fit any of the other categories.

Re: How to create a popupWindow

Postby cubewalker » Thu Dec 30, 2010 6:30 pm

hi bins,

I follow your code and successfully show the popupwindow in my app.

But I found a problem. The popupwindow can not be closed even I call the dismiss() function.
I'm sure the dismiss() function had been ran but no effect.

Any idea?

In fact I'm finding a solution of "Bad Token" error of the popupwindow in my app. I test the app in G1 and no error found. But some users say they have bad token error in different device. Most answer in Google search tell me show the popupwindow in event listener instead of oncreate(). I already did it but no help>"<
cubewalker
Freshman
Freshman
 
Posts: 5
Joined: Fri Nov 12, 2010 5:15 am

Top

Re: How to create a popupWindow

Postby kpl.lokhande » Tue Jan 25, 2011 12:57 pm

Hi bins
GREETINGS OF THE DAY

I am very happy to see posts like this.

Can i implement layout shown in attached file with the help of pop up window. i.e layout of alphabets bar right in the layout, which is above listview.
Attachments
device.png
device.png (26.59 KiB) Viewed 827 times
kpl.lokhande
Freshman
Freshman
 
Posts: 2
Joined: Tue Oct 05, 2010 9:56 am

Re: How to create a popupWindow

Postby rahul9586 » Fri Feb 25, 2011 5:25 am

hi, is there a way to create the popup window in onCreate() instead of on button click? I want to use the poppup window as a menu bar at bottom of screen. I was getting a bad window token error when i wrote the code in onCreate();
rahul9586
Freshman
Freshman
 
Posts: 5
Joined: Fri Jan 21, 2011 5:15 am

Re: How to create a popupWindow in onCreate()

Postby rahul9586 » Wed Mar 02, 2011 5:14 am

Popup window gives a bad token exception if you try to use it directly in onCreate() insead of in an event listener. this is probably because the popup can only be shown when the activity has completely started and is running. i.e. the activity life cycle is complete... in order to use it as soon as activity starts, we have to put it into a new thread that runs after the activity has started. I found a sample implementation which goes like this:


findViewById(R.id.Button01).post(new Runnable() {
public void run() {
pw..showAtLocation(findViewById(R.id.LinearLayout01),
Gravity.CENTER, 0, 0);*/
}
});

this code runs nicely.
rahul9586
Freshman
Freshman
 
Posts: 5
Joined: Fri Jan 21, 2011 5:15 am

Re: How to create a popupWindow

Postby bins1984 » Wed Mar 02, 2011 7:54 am

hi,

you can see the window below ,when popup window comes top of it.but as its a mobile device i think u cannot have focus in both in same time.and u cannot be able to switch.I am not so sure wat exactly u want.
User avatar
bins1984
Experienced Developer
Experienced Developer
 
Posts: 67
Joined: Fri Feb 08, 2008 8:20 am
Location: India

Top
Previous

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 22 guests