Note that there are some explanatory texts on larger screens.

plurals
  1. PODialog Ignore Font Color Html Tag
    primarykey
    data
    text
    <p>I have multiple dialog in one activity and every thing run perfectly and dialog <strong>text</strong> can be </p> <p>fully customized from (<strong>string.xml</strong>) by adding html tags .</p> <p><strong>Activity code :</strong></p> <pre><code>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); } } </code></pre> <p><strong>String.xml:</strong></p> <pre><code>&lt;string name="torusim_places_1"&gt; &lt;![CDATA[ &lt;b&gt;&lt;font color=#008000&gt;* &lt;/b&gt;This is &lt;b&gt;&lt;font color=#008080&gt;First&lt;/b&gt; line in dialog &lt;br/&gt; &lt;b&gt;&lt;font color=#ff00ff&gt;* &lt;/b&gt;This is &lt;b&gt;&lt;font color=#FDD017&gt;Second&lt;/b&gt; line in dialog &lt;br/&gt; &lt;b&gt;&lt;font color=#0000FF&gt;* &lt;/b&gt;This is &lt;b&gt;&lt;font color=#808000&gt;Third&lt;/b&gt; line in dialog &lt;br/&gt; &lt;b&gt;&lt;font color=#59C9FA&gt;* &lt;/b&gt;This is &lt;b&gt;&lt;font color=#0000A0&gt;Fourth&lt;/b&gt; line in dialog &lt;br/&gt; ]]&gt; &lt;/string&gt; </code></pre> <p><strong>output image :</strong></p> <p><img src="https://i.stack.imgur.com/UXmkT.png" alt="enter image description here"></p> <p>BUT i have 20 row so i add dialog 20 times which is redundant , its work fine but i think there is better approach than what i did ,</p> <p><strong>So as per answer of my previous question</strong> <a href="https://stackoverflow.com/questions/16655404/set-custom-dialog-once-into-activity">Set custom dialog once into activity</a></p> <p>i applied the answered code as bellow :</p> <pre><code>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.LayoutParams.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.getDroidNaskh(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) { dialogCreation(Html.fromHtml(getString(R.string.torusim_places_1)).toString()); } }); } 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) { dialogCreation(Html.fromHtml(getString(R.string.torusim_places_2)).toString()); } }); } 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) { dialogCreation(Html.fromHtml(getString(R.string.torusim_places_3)).toString()); } }); } } // this continuing repeated till day 20 // public void handleClick(View v){ //Create an intent to start the new activity. Intent intent = new Intent(); intent.setClass(this,DayGallery.class); intent.putExtra("dayname",day); startActivity(intent); } public void dialogCreation(String 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(arg0); 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(); } } </code></pre> <p>BUT i have one problem with answered code which is <strong>ignorance of font color tag</strong> with the same (<strong>string.xml</strong>)</p> <p>so all words took one color which is set in R.layout.custom_dialog.</p> <p><strong>String.xml:</strong></p> <pre><code>&lt;string name="torusim_places_1"&gt; &lt;![CDATA[ &lt;b&gt;&lt;font color=#008000&gt;* &lt;/b&gt;This is &lt;b&gt;&lt;font color=#008080&gt;First&lt;/b&gt; line in dialog &lt;br/&gt; &lt;b&gt;&lt;font color=#ff00ff&gt;* &lt;/b&gt;This is &lt;b&gt;&lt;font color=#FDD017&gt;Second&lt;/b&gt; line in dialog &lt;br/&gt; &lt;b&gt;&lt;font color=#0000FF&gt;* &lt;/b&gt;This is &lt;b&gt;&lt;font color=#808000&gt;Third&lt;/b&gt; line in dialog &lt;br/&gt; &lt;b&gt;&lt;font color=#59C9FA&gt;* &lt;/b&gt;This is &lt;b&gt;&lt;font color=#0000A0&gt;Fourth&lt;/b&gt; line in dialog &lt;br/&gt; ]]&gt; &lt;/string&gt; </code></pre> <p><strong>output image :</strong></p> <p><img src="https://i.stack.imgur.com/Zym6R.png" alt="enter image description here"></p> <p>any help will be appreciated , thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload