I create many activities and classes in my app. However I have a function to change font size and color in every activity. This function changes text in own activity. When I go to other activity I must change textSize and color again. How can I create a function to change TextView in many classes and activities in one shot?
My app Structure:
Main.java main.xml/
Suad1.java suad1.xml/
Suad2.java suad2.xml/
Suad3.java suad3.xml/
Suad4.java suad4.xml/
I want to change these activity in one time. Here my code in Suad1.class.
public void ShowDialog() {
final AlertDialog.Builder popDialog = new AlertDialog.Builder(this);
final SeekBar seek = new SeekBar(this);
seek.getProgress();
seek.setMax(100);
popDialog.setIcon(R.drawable.conp);
popDialog.setTitle(R.string.menu_settings);
popDialog.setView(seek);
try {
seek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
subtitles.setTextSize(progress);
}
});
}
catch (Exception e) {
e.printStackTrace();
}
popDialog.setSingleChoiceItems(items , -1,
new DialogInterface.OnClickListener() {
int i;
public void onClick(DialogInterface dialog, int item) {
i = item;
if(items[i] =="Blue") {
subtitles.setTextColor(getResources().getColor(R.color.font3));
} else if(items[i] == "Yellow") {
subtitles.setTextColor(getResources().getColor(R.color.font1));
} else if(items[i]== "Red") {
subtitles.setTextColor(getResources().getColor(R.color.font2));
}
}
}
);
// Button
popDialog.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(Suad1.this, "Your setting is complete", Toast.LENGTH_LONG).show();
dialog.dismiss();
}
}
);
popDialog.create();
popDialog.show();
}
And two more questions:
- Can I update SeekBar when out dialog and back again?
- Can I have two Titles or more in one AlertDialog?