Java 对话框忽略字体颜色Html标记

Java 对话框忽略字体颜色Html标记,java,android,html,customdialog,Java,Android,Html,Customdialog,我在一个活动中有多个对话,每件事都能完美运行,对话文本 可能是 通过添加html标记从(string.xml)完全定制 活动代码: public class MyDay extends Activity { final Context context = this; private Button button; TextView tv1,tv2,tv3,tv4; String day; @Override public void onCreate(Bundle savedInstan

我在一个活动中有多个对话,每件事都能完美运行,对话文本 可能是

通过添加html标记从(string.xml)完全定制

活动代码:

public class MyDay extends Activity {
 final Context context = this;
 private Button button;
 TextView tv1,tv2,tv3,tv4;
 String day;

 @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.Layou
      tParams.FLAG_FULLSCREEN); 
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Boolean customTitleSupported =       
     requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);     
setContentView(R.layout.day);  

if (customTitleSupported) {          
 getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title);  
 } 

   initializeTextViews();
 }

private void initializeTextViews() {
 tv1=(TextView)findViewById(R.id.title_tv1); 
 tv1.setTypeface(FontFactory.getBFantezy(getBaseContext()));

 tv2=(TextView)findViewById(R.id.day_tv1);
 tv2.setTypeface(FontFactory.getBFantezy(getBaseContext()));

 tv3=(TextView)findViewById(R.id.day_tv3);
 tv3.setTypeface(FontFactory.getBFantezy(getBaseContext()));

     day=getIntent().getStringExtra("cheese");

if(day.equalsIgnoreCase("Day1")){
    tv1.setText("First Day");       
    tv2.setText(Html.fromHtml(getString(R.string.beginning)));  
    tv3.setText(Html.fromHtml(getString(R.string.day1))); 

    button = (Button) findViewById(R.id.city_button);        
    button.setOnClickListener(new OnClickListener() { 
  public void onClick(View arg0) { 
    // custom dialog
    final Dialog dialog = new Dialog(context,R.style.cust_dialog);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);           
    dialog.setContentView(R.layout.custom_dialog); 
    // set the custom dialog components - text, image and button
    TextView text = (TextView) dialog.findViewById(R.id.dialog_text);
    text.setTypeface(FontFactory.getBFantezy(getBaseContext()));                
    text.setText(Html.fromHtml(getString(R.string.torusim_places_1)));

    Button dialogButton = (Button) dialog.findViewById(R.id.dialog_Button);             
    dialogButton.setTypeface(FontFactory.getBFantezy(getBaseContext()));
    dialogButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
        }
   });
            dialog.show(); 
        }
   });
 }

 else if(day.equalsIgnoreCase("Day2")){
    tv1.setText("Second Day");
    tv2.setText(Html.fromHtml(getString(R.string.beginning)));
    tv3.setText(Html.fromHtml(getString(R.string.day2))); 

    button = (Button) findViewById(R.id.city_button);        
    button.setOnClickListener(new OnClickListener() {    
      public void onClick(View arg0) {   
        // custom dialog
    final Dialog dialog = new Dialog(context,R.style.cust_dialog);                  
     dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);          
     dialog.setContentView(R.layout.custom_dialog);  

    TextView text = (TextView) dialog.findViewById(R.id.dialog_text);               
    text.setTypeface(FontFactory.getBFantezy(getBaseContext()));              
    text.setText(Html.fromHtml(getString(R.string.torusim_places_2)));

    Button dialogButton = (Button) dialog.findViewById(R.id.dialog_Button);         
     dialogButton.setTypeface(FontFactory.getBFantezy(getBaseContext()));
        // if button is clicked, close the custom dialog
       dialogButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                dialog.dismiss(); 
                 }
             });  
                dialog.show();
             }
         });
       }
 else if(day.equalsIgnoreCase("Day3")){
    tv1.setText("Third Day");
    tv2.setText(Html.fromHtml(getString(R.string.beginning)));
    tv3.setText(Html.fromHtml(getString(R.string.day3))); 

    button = (Button) findViewById(R.id.city_button);        
    button.setOnClickListener(new OnClickListener() {    
      public void onClick(View arg0) {   
    // custom dialog
    final Dialog dialog = new Dialog(context,R.style.cust_dialog);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);           
            dialog.setContentView(R.layout.custom_dialog);                  
    TextView text = (TextView) dialog.findViewById(R.id.dialog_text);               
    text.setTypeface(FontFactory.getBFantezy(getBaseContext()));              
    text.setText(Html.fromHtml(getString(R.string.torusim_places_3)));

    Button dialogButton = (Button) dialog.findViewById(R.id.dialog_Button);             
    dialogButton.setTypeface(FontFactory.getBFantezy(getBaseContext()));
        // if button is clicked, close the custom dialog
    dialogButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                dialog.dismiss(); 
            }
       });  
                dialog.show();
          }
      }); 
    }
 }
                   // this continuing repeated till day 20 // 


 public void handleClick(View v){

  Intent intent = new Intent();
  intent.setClass(this,DayGallery.class);
  intent.putExtra("dayname",day);
  startActivity(intent);

              }
        }
<string name="torusim_places_1">
<![CDATA[    
<b><font color=#008000>* </b>This is  <b><font color=#008080>First</b> line in  
    dialog <br/>
<b><font color=#ff00ff>* </b>This is  <b><font color=#FDD017>Second</b> line in  
    dialog <br/>         
<b><font color=#0000FF>* </b>This is  <b><font color=#808000>Third</b> line in 
    dialog <br/> 
<b><font color=#59C9FA>* </b>This is  <b><font color=#0000A0>Fourth</b> line in  
    dialog <br/>
  ]]> 
</string>
<string name="torusim_places_1">
<![CDATA[    
<b><font color=#008000>* </b>This is  <b><font color=#008080>First</b> line in  
    dialog <br/>
<b><font color=#ff00ff>* </b>This is  <b><font color=#FDD017>Second</b> line in  
    dialog <br/>         
<b><font color=#0000FF>* </b>This is  <b><font color=#808000>Third</b> line in 
    dialog <br/> 
<b><font color=#59C9FA>* </b>This is  <b><font color=#0000A0>Fourth</b> line in  
    dialog <br/>
  ]]> 
</string>
String.xml:

public class MyDay extends Activity {
 final Context context = this;
 private Button button;
 TextView tv1,tv2,tv3,tv4;
 String day;

 @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.Layou
      tParams.FLAG_FULLSCREEN); 
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Boolean customTitleSupported =       
     requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);     
setContentView(R.layout.day);  

if (customTitleSupported) {          
 getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title);  
 } 

   initializeTextViews();
 }

private void initializeTextViews() {
 tv1=(TextView)findViewById(R.id.title_tv1); 
 tv1.setTypeface(FontFactory.getBFantezy(getBaseContext()));

 tv2=(TextView)findViewById(R.id.day_tv1);
 tv2.setTypeface(FontFactory.getBFantezy(getBaseContext()));

 tv3=(TextView)findViewById(R.id.day_tv3);
 tv3.setTypeface(FontFactory.getBFantezy(getBaseContext()));

     day=getIntent().getStringExtra("cheese");

if(day.equalsIgnoreCase("Day1")){
    tv1.setText("First Day");       
    tv2.setText(Html.fromHtml(getString(R.string.beginning)));  
    tv3.setText(Html.fromHtml(getString(R.string.day1))); 

    button = (Button) findViewById(R.id.city_button);        
    button.setOnClickListener(new OnClickListener() { 
  public void onClick(View arg0) { 
    // custom dialog
    final Dialog dialog = new Dialog(context,R.style.cust_dialog);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);           
    dialog.setContentView(R.layout.custom_dialog); 
    // set the custom dialog components - text, image and button
    TextView text = (TextView) dialog.findViewById(R.id.dialog_text);
    text.setTypeface(FontFactory.getBFantezy(getBaseContext()));                
    text.setText(Html.fromHtml(getString(R.string.torusim_places_1)));

    Button dialogButton = (Button) dialog.findViewById(R.id.dialog_Button);             
    dialogButton.setTypeface(FontFactory.getBFantezy(getBaseContext()));
    dialogButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
        }
   });
            dialog.show(); 
        }
   });
 }

 else if(day.equalsIgnoreCase("Day2")){
    tv1.setText("Second Day");
    tv2.setText(Html.fromHtml(getString(R.string.beginning)));
    tv3.setText(Html.fromHtml(getString(R.string.day2))); 

    button = (Button) findViewById(R.id.city_button);        
    button.setOnClickListener(new OnClickListener() {    
      public void onClick(View arg0) {   
        // custom dialog
    final Dialog dialog = new Dialog(context,R.style.cust_dialog);                  
     dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);          
     dialog.setContentView(R.layout.custom_dialog);  

    TextView text = (TextView) dialog.findViewById(R.id.dialog_text);               
    text.setTypeface(FontFactory.getBFantezy(getBaseContext()));              
    text.setText(Html.fromHtml(getString(R.string.torusim_places_2)));

    Button dialogButton = (Button) dialog.findViewById(R.id.dialog_Button);         
     dialogButton.setTypeface(FontFactory.getBFantezy(getBaseContext()));
        // if button is clicked, close the custom dialog
       dialogButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                dialog.dismiss(); 
                 }
             });  
                dialog.show();
             }
         });
       }
 else if(day.equalsIgnoreCase("Day3")){
    tv1.setText("Third Day");
    tv2.setText(Html.fromHtml(getString(R.string.beginning)));
    tv3.setText(Html.fromHtml(getString(R.string.day3))); 

    button = (Button) findViewById(R.id.city_button);        
    button.setOnClickListener(new OnClickListener() {    
      public void onClick(View arg0) {   
    // custom dialog
    final Dialog dialog = new Dialog(context,R.style.cust_dialog);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);           
            dialog.setContentView(R.layout.custom_dialog);                  
    TextView text = (TextView) dialog.findViewById(R.id.dialog_text);               
    text.setTypeface(FontFactory.getBFantezy(getBaseContext()));              
    text.setText(Html.fromHtml(getString(R.string.torusim_places_3)));

    Button dialogButton = (Button) dialog.findViewById(R.id.dialog_Button);             
    dialogButton.setTypeface(FontFactory.getBFantezy(getBaseContext()));
        // if button is clicked, close the custom dialog
    dialogButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                dialog.dismiss(); 
            }
       });  
                dialog.show();
          }
      }); 
    }
 }
                   // this continuing repeated till day 20 // 


 public void handleClick(View v){

  Intent intent = new Intent();
  intent.setClass(this,DayGallery.class);
  intent.putExtra("dayname",day);
  startActivity(intent);

              }
        }
<string name="torusim_places_1">
<![CDATA[    
<b><font color=#008000>* </b>This is  <b><font color=#008080>First</b> line in  
    dialog <br/>
<b><font color=#ff00ff>* </b>This is  <b><font color=#FDD017>Second</b> line in  
    dialog <br/>         
<b><font color=#0000FF>* </b>This is  <b><font color=#808000>Third</b> line in 
    dialog <br/> 
<b><font color=#59C9FA>* </b>This is  <b><font color=#0000A0>Fourth</b> line in  
    dialog <br/>
  ]]> 
</string>
<string name="torusim_places_1">
<![CDATA[    
<b><font color=#008000>* </b>This is  <b><font color=#008080>First</b> line in  
    dialog <br/>
<b><font color=#ff00ff>* </b>This is  <b><font color=#FDD017>Second</b> line in  
    dialog <br/>         
<b><font color=#0000FF>* </b>This is  <b><font color=#808000>Third</b> line in 
    dialog <br/> 
<b><font color=#59C9FA>* </b>This is  <b><font color=#0000A0>Fourth</b> line in  
    dialog <br/>
  ]]> 
</string>
但是我对回答的代码有一个问题,那就是忽略字体颜色标记,而使用相同的(string.xml

因此,所有单词都采用了在R.layout.custom\u对话框中设置的一种颜色

String.xml:

public class MyDay extends Activity {
 final Context context = this;
 private Button button;
 TextView tv1,tv2,tv3,tv4;
 String day;

 @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.Layou
      tParams.FLAG_FULLSCREEN); 
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Boolean customTitleSupported =       
     requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);     
setContentView(R.layout.day);  

if (customTitleSupported) {          
 getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title);  
 } 

   initializeTextViews();
 }

private void initializeTextViews() {
 tv1=(TextView)findViewById(R.id.title_tv1); 
 tv1.setTypeface(FontFactory.getBFantezy(getBaseContext()));

 tv2=(TextView)findViewById(R.id.day_tv1);
 tv2.setTypeface(FontFactory.getBFantezy(getBaseContext()));

 tv3=(TextView)findViewById(R.id.day_tv3);
 tv3.setTypeface(FontFactory.getBFantezy(getBaseContext()));

     day=getIntent().getStringExtra("cheese");

if(day.equalsIgnoreCase("Day1")){
    tv1.setText("First Day");       
    tv2.setText(Html.fromHtml(getString(R.string.beginning)));  
    tv3.setText(Html.fromHtml(getString(R.string.day1))); 

    button = (Button) findViewById(R.id.city_button);        
    button.setOnClickListener(new OnClickListener() { 
  public void onClick(View arg0) { 
    // custom dialog
    final Dialog dialog = new Dialog(context,R.style.cust_dialog);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);           
    dialog.setContentView(R.layout.custom_dialog); 
    // set the custom dialog components - text, image and button
    TextView text = (TextView) dialog.findViewById(R.id.dialog_text);
    text.setTypeface(FontFactory.getBFantezy(getBaseContext()));                
    text.setText(Html.fromHtml(getString(R.string.torusim_places_1)));

    Button dialogButton = (Button) dialog.findViewById(R.id.dialog_Button);             
    dialogButton.setTypeface(FontFactory.getBFantezy(getBaseContext()));
    dialogButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
        }
   });
            dialog.show(); 
        }
   });
 }

 else if(day.equalsIgnoreCase("Day2")){
    tv1.setText("Second Day");
    tv2.setText(Html.fromHtml(getString(R.string.beginning)));
    tv3.setText(Html.fromHtml(getString(R.string.day2))); 

    button = (Button) findViewById(R.id.city_button);        
    button.setOnClickListener(new OnClickListener() {    
      public void onClick(View arg0) {   
        // custom dialog
    final Dialog dialog = new Dialog(context,R.style.cust_dialog);                  
     dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);          
     dialog.setContentView(R.layout.custom_dialog);  

    TextView text = (TextView) dialog.findViewById(R.id.dialog_text);               
    text.setTypeface(FontFactory.getBFantezy(getBaseContext()));              
    text.setText(Html.fromHtml(getString(R.string.torusim_places_2)));

    Button dialogButton = (Button) dialog.findViewById(R.id.dialog_Button);         
     dialogButton.setTypeface(FontFactory.getBFantezy(getBaseContext()));
        // if button is clicked, close the custom dialog
       dialogButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                dialog.dismiss(); 
                 }
             });  
                dialog.show();
             }
         });
       }
 else if(day.equalsIgnoreCase("Day3")){
    tv1.setText("Third Day");
    tv2.setText(Html.fromHtml(getString(R.string.beginning)));
    tv3.setText(Html.fromHtml(getString(R.string.day3))); 

    button = (Button) findViewById(R.id.city_button);        
    button.setOnClickListener(new OnClickListener() {    
      public void onClick(View arg0) {   
    // custom dialog
    final Dialog dialog = new Dialog(context,R.style.cust_dialog);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);           
            dialog.setContentView(R.layout.custom_dialog);                  
    TextView text = (TextView) dialog.findViewById(R.id.dialog_text);               
    text.setTypeface(FontFactory.getBFantezy(getBaseContext()));              
    text.setText(Html.fromHtml(getString(R.string.torusim_places_3)));

    Button dialogButton = (Button) dialog.findViewById(R.id.dialog_Button);             
    dialogButton.setTypeface(FontFactory.getBFantezy(getBaseContext()));
        // if button is clicked, close the custom dialog
    dialogButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                dialog.dismiss(); 
            }
       });  
                dialog.show();
          }
      }); 
    }
 }
                   // this continuing repeated till day 20 // 


 public void handleClick(View v){

  Intent intent = new Intent();
  intent.setClass(this,DayGallery.class);
  intent.putExtra("dayname",day);
  startActivity(intent);

              }
        }
<string name="torusim_places_1">
<![CDATA[    
<b><font color=#008000>* </b>This is  <b><font color=#008080>First</b> line in  
    dialog <br/>
<b><font color=#ff00ff>* </b>This is  <b><font color=#FDD017>Second</b> line in  
    dialog <br/>         
<b><font color=#0000FF>* </b>This is  <b><font color=#808000>Third</b> line in 
    dialog <br/> 
<b><font color=#59C9FA>* </b>This is  <b><font color=#0000A0>Fourth</b> line in  
    dialog <br/>
  ]]> 
</string>
<string name="torusim_places_1">
<![CDATA[    
<b><font color=#008000>* </b>This is  <b><font color=#008080>First</b> line in  
    dialog <br/>
<b><font color=#ff00ff>* </b>This is  <b><font color=#FDD017>Second</b> line in  
    dialog <br/>         
<b><font color=#0000FF>* </b>This is  <b><font color=#808000>Third</b> line in 
    dialog <br/> 
<b><font color=#59C9FA>* </b>This is  <b><font color=#0000A0>Fourth</b> line in  
    dialog <br/>
  ]]> 
</string>

*这是第一行
对话框
*这是第二行 对话框
*这是第三行 对话框
*这是第四行 对话框
]]>
输出图像:

public class MyDay extends Activity {
 final Context context = this;
 private Button button;
 TextView tv1,tv2,tv3,tv4;
 String day;

 @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.Layou
      tParams.FLAG_FULLSCREEN); 
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Boolean customTitleSupported =       
     requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);     
setContentView(R.layout.day);  

if (customTitleSupported) {          
 getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title);  
 } 

   initializeTextViews();
 }

private void initializeTextViews() {
 tv1=(TextView)findViewById(R.id.title_tv1); 
 tv1.setTypeface(FontFactory.getBFantezy(getBaseContext()));

 tv2=(TextView)findViewById(R.id.day_tv1);
 tv2.setTypeface(FontFactory.getBFantezy(getBaseContext()));

 tv3=(TextView)findViewById(R.id.day_tv3);
 tv3.setTypeface(FontFactory.getBFantezy(getBaseContext()));

     day=getIntent().getStringExtra("cheese");

if(day.equalsIgnoreCase("Day1")){
    tv1.setText("First Day");       
    tv2.setText(Html.fromHtml(getString(R.string.beginning)));  
    tv3.setText(Html.fromHtml(getString(R.string.day1))); 

    button = (Button) findViewById(R.id.city_button);        
    button.setOnClickListener(new OnClickListener() { 
  public void onClick(View arg0) { 
    // custom dialog
    final Dialog dialog = new Dialog(context,R.style.cust_dialog);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);           
    dialog.setContentView(R.layout.custom_dialog); 
    // set the custom dialog components - text, image and button
    TextView text = (TextView) dialog.findViewById(R.id.dialog_text);
    text.setTypeface(FontFactory.getBFantezy(getBaseContext()));                
    text.setText(Html.fromHtml(getString(R.string.torusim_places_1)));

    Button dialogButton = (Button) dialog.findViewById(R.id.dialog_Button);             
    dialogButton.setTypeface(FontFactory.getBFantezy(getBaseContext()));
    dialogButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
        }
   });
            dialog.show(); 
        }
   });
 }

 else if(day.equalsIgnoreCase("Day2")){
    tv1.setText("Second Day");
    tv2.setText(Html.fromHtml(getString(R.string.beginning)));
    tv3.setText(Html.fromHtml(getString(R.string.day2))); 

    button = (Button) findViewById(R.id.city_button);        
    button.setOnClickListener(new OnClickListener() {    
      public void onClick(View arg0) {   
        // custom dialog
    final Dialog dialog = new Dialog(context,R.style.cust_dialog);                  
     dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);          
     dialog.setContentView(R.layout.custom_dialog);  

    TextView text = (TextView) dialog.findViewById(R.id.dialog_text);               
    text.setTypeface(FontFactory.getBFantezy(getBaseContext()));              
    text.setText(Html.fromHtml(getString(R.string.torusim_places_2)));

    Button dialogButton = (Button) dialog.findViewById(R.id.dialog_Button);         
     dialogButton.setTypeface(FontFactory.getBFantezy(getBaseContext()));
        // if button is clicked, close the custom dialog
       dialogButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                dialog.dismiss(); 
                 }
             });  
                dialog.show();
             }
         });
       }
 else if(day.equalsIgnoreCase("Day3")){
    tv1.setText("Third Day");
    tv2.setText(Html.fromHtml(getString(R.string.beginning)));
    tv3.setText(Html.fromHtml(getString(R.string.day3))); 

    button = (Button) findViewById(R.id.city_button);        
    button.setOnClickListener(new OnClickListener() {    
      public void onClick(View arg0) {   
    // custom dialog
    final Dialog dialog = new Dialog(context,R.style.cust_dialog);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);           
            dialog.setContentView(R.layout.custom_dialog);                  
    TextView text = (TextView) dialog.findViewById(R.id.dialog_text);               
    text.setTypeface(FontFactory.getBFantezy(getBaseContext()));              
    text.setText(Html.fromHtml(getString(R.string.torusim_places_3)));

    Button dialogButton = (Button) dialog.findViewById(R.id.dialog_Button);             
    dialogButton.setTypeface(FontFactory.getBFantezy(getBaseContext()));
        // if button is clicked, close the custom dialog
    dialogButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                dialog.dismiss(); 
            }
       });  
                dialog.show();
          }
      }); 
    }
 }
                   // this continuing repeated till day 20 // 


 public void handleClick(View v){

  Intent intent = new Intent();
  intent.setClass(this,DayGallery.class);
  intent.putExtra("dayname",day);
  startActivity(intent);

              }
        }
<string name="torusim_places_1">
<![CDATA[    
<b><font color=#008000>* </b>This is  <b><font color=#008080>First</b> line in  
    dialog <br/>
<b><font color=#ff00ff>* </b>This is  <b><font color=#FDD017>Second</b> line in  
    dialog <br/>         
<b><font color=#0000FF>* </b>This is  <b><font color=#808000>Third</b> line in 
    dialog <br/> 
<b><font color=#59C9FA>* </b>This is  <b><font color=#0000A0>Fourth</b> line in  
    dialog <br/>
  ]]> 
</string>
<string name="torusim_places_1">
<![CDATA[    
<b><font color=#008000>* </b>This is  <b><font color=#008080>First</b> line in  
    dialog <br/>
<b><font color=#ff00ff>* </b>This is  <b><font color=#FDD017>Second</b> line in  
    dialog <br/>         
<b><font color=#0000FF>* </b>This is  <b><font color=#808000>Third</b> line in 
    dialog <br/> 
<b><font color=#59C9FA>* </b>This is  <b><font color=#0000A0>Fourth</b> line in  
    dialog <br/>
  ]]> 
</string>


任何帮助都将不胜感激,谢谢

我试过这样做:它给我(三星Galaxy Note N7000)一个橙色*和绿色的“第一个”字

 <string name="torusim_places_1">
     <![CDATA[<b><font color="#FF8000"> * </font></b>This is  <b><font color="#008080">First</font></b>line in  
 dialog<br />]]>
    </string>

并将其称为
对话框创建(R.string.torusim\u places\u 1)

font color='#008000',你错过了“”?@blackbelt我上面的String.xml与我的代码完美配合,但在应用回答的代码时不起作用,我也尝试了你的评论,它给了我错误,谢谢。我认为问题不在于如何在String.xml中编写标记,而在于更改后的类代码中,它会影响应用字体颜色标记,因为我检查了你的代码,仍然存在相同的问题,请检查更新的帖子,图片也添加了用于两个代码的相同string.xml,谢谢为了了解问题所在,在DialogCreation中,更改text.setText(arg0);使用text.setText(Html.fromHtml(getString(R.string.torusim_places_1));并检查它是否有任何区别我更改了字体颜色,也正确更改了字体颜色,但我想按顺序分配每个torusim_位置,我该怎么做呢,谢谢issmues似乎与Spanable->String转换有关很多我的主人,请你看看我的另一个问题,我努力了我很想解决,但没办法,谢谢,