so umm my if else is buggy it only shows the else option and not the if(data == "heavy") i just want that is type is equal to heavy and not light then one of the linearlayout vanishes goes invisible and the other way around... help me please...
heres my code:
Intent intentType = getIntent();
String valueType = intentType.getStringExtra("type");
EditText displayType = (EditText) findViewById(R.id.editTextType1);
displayType.setText(valueType);
LinearLayout one = (LinearLayout) findViewById(R.id.type1);
LinearLayout two = (LinearLayout) findViewById(R.id.type2);
String data = displayType.getText().toString();
if(data == "heavy") {
one.setVisibility(View.VISIBLE);
two.setVisibility(View.INVISIBLE);
} else {
one.setVisibility(View.INVISIBLE);
two.setVisibility(View.VISIBLE);
}
the codes from previous .java file:
EditText units = (EditText) findViewById(R.id.editTextUnits);
units.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(new Intent(MainActivity.this, MainActivity3.class));
Intent intentType = getIntent();
String valueType = intentType.getStringExtra("type");
intent.putExtra("type", valueType);
startActivity(intent);
}
});
the other .java file
private void SetOnClickWeightButton(){
Button btn = (Button) findViewById(R.id.buttonWeight);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity2.this, MainActivity.class);
intent.putExtra("type", "heavy");
startActivity(intent);
}
});
}
private void SetOnClickLengthtButton(){
Button btn = (Button) findViewById(R.id.buttonLength);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity2.this, MainActivity.class);
intent.putExtra("type", "light");
startActivity(intent);
}
});
}