开发者

Having trouble with PopupWindow

I'm just starting to go through tutorials for writing Android apps. My first app is hopefully going to be very simple, but I am having a little trouble with the next step. I have my main GUI working, which is a开发者_C百科 simple LinearLayout with several Buttons arranged vertically. When I click on the Connect button, I want a PopupWindow to appear, with the following information:

TextView: "Enter IP Address"
EditText: <ip address should get entered here>
Button:   "OK" --> connects to a PC listening for requests

The problem is, when the PopupWindow is created, I can barely make out any of the text in the TextView, but it's definitely there. More strangely, I can't see the EditText or the Button. It's almost as if the PopupWindow is fading into view, but gets frozen partway.

I used the code from this answer on SO for getting the PopupWindow to (kind of) work.

Once the PopupWindow (kind of) displays, my app is frozen because it's obscuring the main GUI at that point.

I have also added calls to showAsDropDown() and dismiss(), and when I do this the PopupWindow definitely disappears because I regain responsiveness in my main GUI.

Can anyone explain what's going on here?

Here's what I am talking about regarding the barely-visible TextView:

Having trouble with PopupWindow


Does it absolutely have to be a PopupWindow? Would a custom Dialog do instead? You can specify your own layout & buttons etc. Some examples using custom dialogs are here, here and here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜