开发者

popup windows in android?

开发者 https://www.devze.com 2023-03-19 19:22 出处:网络
Pretty new to android so excuse me if this is a really obvious question. Say my application has a bunch of TextViews, each one showing the attributes of a certain product (name, price, etc). I have a

Pretty new to android so excuse me if this is a really obvious question.

Say my application has a bunch of TextViews, each one showing the attributes of a certain product (name, price, etc). I have a button next to each of these TextViews labeled "modify".

How do I make it so that when I press the modify button next开发者_如何学编程 to a certain attribute, a popup window with a space to enter text into comes up so that the user can enter text into this box and then have the actual attribute listing on the original page change? Actually I just need a push in the right direction with creating this popup text field... not sure if there is already some built in functionality for this or if not, what would be the best way to create this kind of thing.

Thanks.


Why not have the modify button set TextEdit.setEnabled(true); and then change focus with TextEdit.setFocus? Note that both of these are inherited from view

If you really want a dialog you might want to looking into the AlertDialog.Builder. I know you can use it with buttons and radio buttons, but I'm not sure you can get it to work with a TextView.


Use a code like this for the input popup: Android dialog input text

In the positive button handler, set your edittext content programmatically like this:

myEditText.setText(value).

As simple as that. The only difference with a standard GUI framework is that you don't retrieve the value as a result of the popup function. Instead, you must provide an action handler.

0

精彩评论

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

关注公众号