I have a problem regarding the following:
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
temp=a.getItemAtPosition(position).toString();
Toast.makeText(ne.this, temp, Toast.LENGTH_SHORT).show();
if (temp=="Aries")
{
ViewFlipper viewflipper= (ViewFlipper) findViewById(R.id.viewflipper);
Toast.makeText(ne.this, temp, Toast.LENGTH_SHORT).show();
}
if (temp=="Taurus")
{
ViewFlipper viewflipper= (ViewFlipper) findViewById(R.id.viewflipper);
Toast.makeText(ne.this, temp, Toast.LENGTH_SHORT).show();
}
if (temp=="Libra")
{
ViewFlipper viewflipper= (ViewFlipper) findViewById(R.id.viewflipper);
Toast.makeText(ne.this, temp, Toast.LENGTH_SHORT).show();
}
when I click on the item it shows me the string on first view.but I am not going on to the second view. and also on first view when I click other item still it shows first output.
i.e. if I select Aries in the first view It shows me aries in the toast window but doesn't go to the second view. and again I am pressing other item say Taurus, still it shows Aries to me.
You need to compare strings with the .equals method, not by ==. Your temp is "Aries" but it is a different string than the one you are testing for equality against so your temp == "Aries" returns false. You need to write it temp.equals("Aries").