简体   繁体   English

想要将textview放在alertdialog中的“ multiple selection”上方

[英]Wanted to place textview above Multi choice in alertdialog

I'm trying to create a dialog with a clock on the top and days of the week at the bottom. 我正在尝试创建一个对话框,该对话框的顶部为时钟,底部为星期几。 But I'm not able to place the clock above the setMultiChoiceItems. 但是我无法将时钟放在setMultiChoiceItems上方。

public void onFabClick(){


    clock = new TextView(this);

    //Setting Listener for Clock.
    clock.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //Calling Time picker
            timepicker();

        }
    });

    AlertDialog.Builder adb = new AlertDialog.Builder(this);
    adb.setView(clock);
    final String[] Colors = new String[]{
            "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
    };
    final ArrayList<Integer> selectedItems = new ArrayList<Integer>();
    final boolean[] preCheckedItems = new boolean[]{
            true,true,true,true,true,true,true
    };
    adb.setMultiChoiceItems(Colors, preCheckedItems, new DialogInterface.OnMultiChoiceClickListener(){
        @Override
        public void onClick(DialogInterface dialog, int which, boolean isChecked){
//Insert Code here
    });

    adb.setPositiveButton("Ok", new DialogInterface.OnClickListener(){
        @Override
        public void onClick(DialogInterface dialog, int which){
           //Test
            Log.d("alertdialog!!!!","Clicked OK");
        }
    });

    adb.setNeutralButton("Cancel", null});

    adb.show();
}

You can create layout file with all items and order you exactly need. 您可以创建包含所有项目和所需的订单的布局文件。 Then just use .setView(view); 然后只需使用.setView(view); to your AlertDialog.Builder() Something like this 到您的AlertDialog.Builder() 东西

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM