开发者

AlertDialog setSingleChoice without radio buttons

I am using an alertDialog to display data similar to a spinner. Is there a way to move the active selection (like in setSingleChoice) using setItems ?

I want the displayed list to look like a spinner, withou开发者_如何学JAVAt the radio buttons.


Check out this page from the Android API. You can create a list of items to display. The array length can be as long as you want. The list will scroll when the number of items gets big enough. Very much like a spinner.

final CharSequence[] items = {"Red", "Green", "Blue"};

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Pick a color");
builder.setItems(items, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int item) {
        Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
    }
});
AlertDialog alert = builder.create();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜