Hi I have a spinner (spinner5) and whenever the user selects an item that says “age” I want the textview to change to 21. I have tried the following but it doesnt work. I can do this by using if (getSelectedItemPosition() == 1) but the spinner’s contents are dynamic so thats not an option.
if (spinner5.getSelectedItem().toString()=="age"){
textArea.setText("21");
}
Always Use
.equalswhen compare two string because==only use forPrimitive data types.equals=compare two string value===compare two string refrences