.setTextColor working in portrait but not landscape
I am really stumped here. I have been searching around on Google for an
answer for hours.
The app is working how it should in portrait mode but not landscape.
When a waist length is typed, gender selected and the calculate button
clicked It should change the color of the relevant result; Ideal, High,
Very High. (Which works fine in portrait mode, however in landscape
nothing happens.
Here is the code:
public class Waistcircumference extends Activity {
Button calculatewaist;
EditText waist_edit_text1;
RadioGroup gender_radio_group1;
RadioButton gender_radio_male, gender_radio_female;
Spinner waist_spinner;
TextView ideal, high, veryhigh;
String waist_unit, waist;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_waistcircumference);
// Show the Up button in the action bar.
setupActionBar();
}
public void calculateClickHandler(View view) {
if (view.getId() == R.id.calculatewaist) {
// get the references to the widgets
EditText waist_edit_text1 =
(EditText)findViewById(R.id.waist_edit_text1);
TextView ideal = (TextView)findViewById(R.id.ideal);
TextView high = (TextView)findViewById(R.id.high);
TextView veryhigh = (TextView)findViewById(R.id.veryhigh);
waist_spinner = (Spinner)findViewById(R.id.waist_spinner);
gender_radio_male =
(RadioButton)findViewById(R.id.gender_radio_male);
gender_radio_female =
(RadioButton)findViewById(R.id.gender_radio_female);
// Get the users values from the widget references
waist_unit = waist_spinner.getSelectedItem().toString();
float waist =
Float.parseFloat(waist_edit_text1.getText().toString());
// Convert Inches to CM
if (waist_unit.equals("INCHES")) {
waist = (float) (waist * 2.54);
}
// Interpret what Waist Circumference result means for male
if (waist < 94 && (gender_radio_male.isChecked())){
ideal.setTextColor(getResources().getColor(R.color.title_color));
} else if (waist < 103 &&
(gender_radio_male.isChecked())) {
high.setTextColor(getResources().getColor(R.color.title_color));
} else if (waist > 102 &&
(gender_radio_male.isChecked())) {
veryhigh.setTextColor(getResources().getColor(R.color.title_color));
}
// Interpret what Waist Circumference result means for female
if (waist < 80 && (gender_radio_female.isChecked())) {
ideal.setTextColor(getResources().getColor(R.color.title_color));
} else if (waist < 89 &&
(gender_radio_female.isChecked())) {
high.setTextColor(getResources().getColor(R.color.title_color));
} else if (waist > 88 &&
(gender_radio_female.isChecked())) {
veryhigh.setTextColor(getResources().getColor(R.color.title_color));
}
};
}
No comments:
Post a Comment