There is a dialogue guidedialog . How to change the color of its title ( Title ) program. And if you can not programmatically, how can you?

 final AlertDialog.Builder guidedialog = new AlertDialog.Builder(this); final View relativeLayout = getLayoutInflater().inflate(R.layout.guide_1, null); TextView textView = (TextView) relativeLayout.findViewById(R.id.textGuide); guidedialog.setTitle("Здравствуй!"); guidedialog.setView(relativeLayout); textView.setText("Вы достигли своей цели. Вы можете прямо сейчас начать новую, или сделать это позже!"); guidedialog.setPositiveButton("Понятно!", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { checkExp(); trueReset(mSqLiteDatabase); getActivity().finish(); dialog.dismiss(); } }); textView.setTextColor(Color.parseColor("#333")); guidedialog.create(); guidedialog.show(); 
  • Show the dialogue code. Possible options depend on the implementation of the dialogue. - Sergey Gornostaev

2 answers 2

Like this

 AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("Тест"); AlertDialog d = builder.create(); int textViewId = d.getContext().getResources().getIdentifier("android:id/alertTitle", null, null); TextView tv = (TextView) d.findViewById(textViewId); tv.setTextColor(Color.RED); d.show(); 
  • It did not work. tv is null. Why so - I do not know ... What to do? - Mr Klonwar
  • one
    Which AlertDialog are you using? What device are you testing? - Flippy
  • Simple alertdialog with buttons. I'm testing on my Doogee X6 device on Android 5.1. I solved the problem, I needed the setCustomTitle method - Mr Klonwar

I solved the problem in the following way: I created a separate xml with a text field of the desired color and connected it to my dialog through the setCustomView(); method setCustomView();