In my applicatin I want to change the value of a variable dynamically , Based on string . Here is what I have tried
public void onClick(View v)
{
switch (v.getId())
{
case R.id.btCalculate:
int column = Integer.parseInt((String) spColumn
.getSelectedItem());
int inch = Integer.parseInt((String) spInch.getSelectedItem());
int colum_inch = column*inch ;
int MULTIUPLIER ;
if (page_number=="FirstPage(Color)Minimum12Maximum80ColumnInch-14500PerColumn/Inch")
{
MULTIUPLIER=20;
}
else if (page_number=="3rd Page Color: 9000") {
MULTIUPLIER=9000;
}
else {
MULTIUPLIER=10;
}
if (colum_inch<4) {
tvAmount.setText(page_number);
} else {
tvAmount.setText((MULTIUPLIER *colum_inch) + "");
}
break;
}
}
Here the variable page_number is a string which stores the text of clicked button . In my previous activity I have two button , one button text is "FirstPage(Color)Minimum12Maximum80ColumnInch-14500PerColumn/Inch" another "3rd Page Color: 9000" . But the problem is in my out the MULTIPLIER is always set to "10" . No matter which button I have clicked . How can I resolve this . How can I change the value of that variable (MULTIPLIER) based the text of clicked button .