2016-06-10 71 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> 

我沒有測試這個雖然。祝你好運!

相關問題