2016-12-08 46 views
0

ラジオボタンの色を変更するにはどうすればよいですか?下の画像は、ラジオボタンがデフォルトで青色であることを示していますが、これを変更したいと思います。単一選択アラートダイアログの色を変更する方法は?

enter image description here

私のコードです:

AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
        context); 
      alertDialogBuilder.setCustomTitle(promptsView); 
      alertDialogBuilder.setItems(frequencyName, null); 
      // alertDialogBuilder.setTitle("SELECT FREQUENCY"); 


      alertDialogBuilder.setSingleChoiceItems(frequencyName, -1, new DialogInterface.OnClickListener() { 
       @Override 
       public void onClick(DialogInterface dialogInterface, int i) { 

        selectedFre = frequencyName[i]; 
       } 
      }); 

      alertDialogBuilder 
        .setCancelable(false) 
        .setPositiveButton("OK", 
          new DialogInterface.OnClickListener() { 
           public void onClick(DialogInterface dialog, int id) { 

            txtFrequency.setText(selectedFre); 
           } 
          }) 
        .setNegativeButton("Cancel", 
          new DialogInterface.OnClickListener() { 
           public void onClick(DialogInterface dialog, int id) { 
            dialog.cancel(); 
           } 
          }); 


      AlertDialog alertDialog = alertDialogBuilder.create(); 


      alertDialog.show(); 
+2

の重複:あなたは、パラメータが何であるかを教えてhttp://stackoverflow.com/questions/23255776/android-alert-dialog-replace-default-blue-with-another-color –

+0

Thanks..can彼らはこのメソッドでパスしています。res.getIdentifier( "titleDivider"、 "id"、 "android"); –

+0

https://developer.android.com/reference/android/content/res/Resources.html#getIdentifier(java.lang.String、java.lang.String、java.lang.String)をご覧ください。基本的にそれは言う:パッケージ "アンドロイド"から "titleDivider"のIDを取得 –

答えて

1

AlertDialog

<style name="MaterialThemeDialog" parent="Theme.AppCompat.Light.Dialog.Alert"> 
    <item name="colorAccent">@color/action_bar_background</item> 
</style> 

ために対応するスタイルを作成します。たとえば以下のようなそのスタイルを使用してAlertDialog.Builderを作成します。

AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
      getActivity(), 
      R.style.MaterialThemeDialog); 
    alertDialogBuilder.setTitle(R.string.image_resolution); 
    alertDialogBuilder.setSingleChoiceItems(R.array.quality_labels, getPosition(), this); 

    AlertDialog alertDialog = alertDialogBuilder.create(); 
    alertDialog.show(); 
+0

おかげでたくさんのおい...私のために働いています..私はu.thanks再びupvoted .. –

+0

ようこそ。あなたの質問の解決策であれば、私の答えを受け入れてください。 –

関連する問題