i m creating app in which i m taking Radio Button Value From RadioGroup when i m Comparing the Value in if Statement it is not working. Here is Java code that i m using.
if(radioQuizeGroup.getText() == "History"){
Log.d("History", "Activity");
Toast.makeText(StartQuize.this,"History sss ss ", Toast.LENGTH_SHORT).show();
}
else{
Log.d("History", "Error ");
}
and i m getting Error in Error log,
here is Error Log
01-05 07:15:02.885: D/gralloc_goldfish(2035): Emulator without GPU emulation detected.
01-05 07:15:04.165: I/Choreographer(2035): Skipped 43 frames! The application may be doing too much work on its main thread.
01-05 07:15:05.245: D/dalvikvm(2035): GC_FOR_ALLOC freed 86K, 5% free 3139K/3280K, paused 18ms, total 32ms
01-05 07:15:15.236: D/History(2035): Error
Please Help me
It is recommended to use
if(radioQuizeGroup.getText().equals("History"))
rather than
if(radioQuizeGroup.getText() == "History")
Since the ==
compares the location of the objects and .equals()
compares the value of the objects