my code not goes in else statement
below is my code which check when go in second activity if mode="search"
true then School_name= this value else this value when user click
imageview or listview problem is if i click form imageview is return true
this statement if (( mode.compareTo("search")==0) ) and get value from if
(( mode.compareTo("search")==0) ) if is flase not go else statement tell
me what is wrong in my code
public class HomeMenu extends Activity {
public static String mode;
editText2 = (EditText) findViewById(R.id.editText2);
ImageView imageView1 = (ImageView) findViewById(R.id.imageView1);
imageView1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mode="search";
Intent iMenuList = new Intent(HomeMenu.this, SecondStep.class);
Serachvalue=editText2.getText().toString();
iMenuList.putExtra("Serachvalue", Serachvalue);
startActivity(iMenuList);
}
});
listMainMenuhome = (ListView) findViewById(R.id.listMainMenuhome);
listMainMenuhome.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long
arg3) {
Intent iMenuList = new Intent(HomeMenu.this, SecondStep.class);
iMenuList.putExtra("School_name", Category_name.get(position));
startActivity(iMenuList);
}
});
public class SecondStep extends Activity {
String mode;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.secondstep);
mode=HomeMenu.mode;
if (( mode.compareTo("search")==0) )
{
Bundle bundle = this.getIntent().getExtras();
School_name = bundle.getString("Serachvalue");
}
else
{
Bundle bundle = this.getIntent().getExtras();
School_name = bundle.getString("School_name");
}
No comments:
Post a Comment