开发者

How do I create a dialog open widget?

开发者 https://www.devze.com 2023-02-28 08:20 出处:网络
I am very new to android development and am trying to find my feet. I am trying to create a settings activity with a pop-up dialog. But I am having difficulty finding how the dialog open options are c

I am very new to android development and am trying to find my feet. I am trying to create a settings activity with a pop-up dialog. But I am having difficulty finding how the dialog open options are created. The sort of thing I am looking for is on the android (2.2) Home>Menu>Settings>Data & Time. The 'Sele开发者_运维百科ct date format' option has a little down arrow and produces a popup dialog. This seems like a really common design, is there a standard widget for this type of option?

OK I may have got this now. I think you use a textview with right drawable, and then use the stock icon: android:drawableRight="@drawable/android:ic_menu_more" ?


Create a Dialog and then infalte the layout using the LayoutInflater

Dialog listDialog = new Dialog(this);
    listDialog.setTitle("Select Item");
     LayoutInflater li = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     View v = li.inflate(R.layout.list, null, false);
     listDialog.setContentView(v);
     listDialog.setCancelable(true);
     listDialog.show();

list is the name of the xml file which contains the components


I think that that option is not a dialog but a Spinner with a different layout.

The HelloViews Tut is useful in learning about all the views

http://developer.android.com/resources/tutorials/views/index.html

And here is the part about the spinner

http://developer.android.com/resources/tutorials/views/hello-spinner.html

0

精彩评论

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