首页 > 其他分享 >对话框的多选

对话框的多选

时间:2023-06-20 22:01:22浏览次数:30  
标签:多选 对话框 void DialogInterface options protected new public

public class MultiSelectionDialogExample extends Activity 
{
 protected CharSequence[] _options = { "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune" };
 protected boolean[] _selections =  new boolean[ _options.length ];
 
 protected Button _optionsButton;
 
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
       
        setContentView(R.layout.main);
        
        _optionsButton = ( Button ) findViewById( R.id.button );
        _optionsButton.setOnClickListener( new ButtonClickHandler()  );
    }
    
    public class ButtonClickHandler implements View.OnClickListener {
  public void onClick( View view ) {
   showDialog( 0 );
  }
 }
    
 @Override
 protected Dialog onCreateDialog( int id ) 
 {
  return 
  new AlertDialog.Builder( this )
         .setTitle( "Planets" )
         .setMultiChoiceItems( _options, _selections, new DialogSelectionClickHandler() )
         .setPositiveButton( "OK", new DialogButtonClickHandler() )
         .create();
 }
 
 
 public class DialogSelectionClickHandler implements DialogInterface.OnMultiChoiceClickListener
 {
  public void onClick( DialogInterface dialog, int clicked, boolean selected )
  {
   Log.i( "ME", _options[ clicked ] + " selected: " + selected );
  }
 }
  public class DialogButtonClickHandler implements DialogInterface.OnClickListener
 {
  public void onClick( DialogInterface dialog, int clicked )
  {
   switch( clicked )
   {
    case DialogInterface.BUTTON_POSITIVE:
     printSelectedPlanets();
     break;
   }
  }
 }
 
 protected void printSelectedPlanets(){
  for( int i = 0; i < _options.length; i++ ){
   Log.i( "ME", _options[ i ] + " selected: " + _selections[i] );
  }
 }
}

标签:多选,对话框,void,DialogInterface,options,protected,new,public
From: https://blog.51cto.com/u_16166892/6525408

相关文章

  • 自定义可编辑的对话框
    Dialogdialog=newDialog(this);dialog.setContentView(R.layout.your_dialog_file);ButtonyourButton=dialog.findViewById(R.id.yourButton);finalEditTexttext=dialog.findViewById(R.id.yourTextEdit);yourButton.setOnClickListener({publicvo......
  • 控制dialog对话框的大小
    publicclassSharePostextendsDialog{@OverridepublicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.adaptor_contentsharepost);LayoutParamsparams=getWindow().getAt......
  • TableRow 背景问题以及修改对话框标题高度或者图片
    <TableRowxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/admin_row"android:layout_width="fill_parent"android:layout_height="wrap_content"......
  • element 对话框标头样式美化
    /deep/.el-dialog__body{padding-top:27px;padding-left:42px;padding-right:38px;}/deep/.el-dialog{background:#F8FAFC;border-radius:12px;margin-top:7vh!important;}/deep/.el-dialog__header{position:relative;font-size......
  • 解决方案 | pyautogui实现等待特定图片(对话框)出现(可设置等待超时时间)
    1、问题为了等待某个【转换完毕】的图片(对话框)出现,如何设置?   2、解决方案代码如下下面代码实现的是:设置超时时间为10s,当你在完成前序工作以后,代码开始进入等待,一旦你的特定图片出现了,马上探测到它的位置并且实现点击按钮。(注意:如果等待时间超过了10s,那么就会返回提示:T......
  • vc的模态对话框和非模态对话框
    GenerallySpeaking(1)创建一非模态对话框 CMyDlg*pMainWnd=newCMyDlg;pMainWnd->Create();(2)创建一模态对话框CMyDlgdlg;dlg.Domdal();   非模态的对话框是独立的,就是说和主程序可以同时交换数据,而模态的对话框则只能和自己交......
  • odoo16弹出对话框中显示SearchPanel
    在odoo中,有些数据模型的Search视图可能会定义关于SearchPanel的部分,但这部分定义不会在弹出对话框中显示。如员工的list视图显示如下: 但如果我们在一个挑选员工的弹出对话框中,显示是这样子的。 这样如果员工较多,我们还要进一步输入搜索条件来进行过虑,不太方便操作。那如果......
  • 前端vue基于原生check增强单选多选插件
    前端vue基于原生check增强单选多选插件, 下载完整代码请访问uni-app插件市场地址:https://ext.dcloud.net.cn/plugin?id=12979效果图如下:     ####使用方法```使用方法<!--多选组件 checkData:多选数据 @change:多选事件 --><ccCheckView:checkDa......
  • select2多选下拉框
    <!DOCTYPEhtml><html><head><metacharset="UTF-8"><title></title><linkrel="stylesheet"type="text/css"href="https://cdnjs.cloudflare.com/ajax/libs/selec......
  • select 多选回显的时候input高度问题
    select多选回显的时候input高度没撑开内容超出setTimeout(function(){if(document.querySelector('.el-cascader__tags')){document.querySelector('#el-cascader.el-input__inner').style.setProperty('height',`${document......