2016-06-10 44 views
0

在出现某处的AlertDialog中有另一个CheckMark Lollypop!我需要删除它并留下你自己的。提示,谁可以面对?如何删除AlertDialog.Multiple中的第一个选中标记选项

enter image description here

AlertDialog:

mSurchargeBtn.setOnClickListener(new View.OnClickListener() { 
    @Override 
    public void onClick(View v) { 

     boolean[] checkedItems = new boolean[surchargeListNames.length]; 
     int count = surchargeListNames.length; 

     for (int i = 0; i < count; i++) 
      checkedItems[i] = selectedSurchargeItems.contains(surchargeListNames[i]); 

     AlertDialog.Builder builder = new AlertDialog.Builder(DetailsActivity.this, R.style.AlertDialogCustom); 
     builder.setMultiChoiceItems(surchargeListNames, checkedItems, new DialogInterface.OnMultiChoiceClickListener() { 
      @Override 
      public void onClick(DialogInterface dialog, int which, boolean isChecked) { 
       if (isChecked) 
        selectedSurchargeItems.add(surchargeListNames[which]); 
       else 
        selectedSurchargeItems.remove(surchargeListNames[which]); 
      } 
     }); 
     builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { 
      @Override 
      public void onClick(DialogInterface dialog, int which) { 

      } 
     }); 

     AlertDialog dialog = builder.create(); 
     dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); 

     dialog.show(); 
} 

风格:

<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert"> 
    <item name="android:checkMark">?android:attr/textCheckMark</item> 
</style> 

回答

1

你也许可以定义延伸的风格Widget.AppCompat.CompoundButton.CheckBox

例如

<style name="mycheckbox" parent="Widget.AppCompat.CompoundButton.CheckBox"> 
    <item name="android:button">@null</item> 
</style> 

,并在你的主要风格

<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert"> 
    <item name="android:checkMark">?android:attr/textCheckMark</item> 
    <item name="android:checkboxStyle">@style/mycheckbox</item> 
</style> 

我没有测试这个虽然。祝你好运!

相关问题