Skip to content Skip to sidebar Skip to footer

Button No Longer Does What It Is Supposed To Do

I have a button that is meant to swap from one activity to another which use to work but ever since i added the coding for another button to call for zxing's scanning feature the b

Solution 1:

For both buttons You are adding Same Listener

addListenerOnButton();

addListenerOnButton1();

please change in button2 accordingly

Solution 2:

publicclassMainActivityextendsActivity {
Button bt, bt2;
            @OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_main);

                bt = (Button) findViewById(R.id.scan);
                bt2 = (Button) findViewById(R.id.getResults);



                bt.setOnClickListener(newOnClickListener() {

                    @OverridepublicvoidonClick(View v) {
                        // TODO Auto-generated method stub// do initiatescan
                    }
                });

                bt2.setOnClickListener(newOnClickListener() {

                    @OverridepublicvoidonClick(View arg0) {

                        Intentintent=newIntent(MainActivity.this, ScanResult.class);
                        startActivity(intent);



                    }

                });



            }

    publicvoidonActivityResult(int requestCode, int resultCode, Intent intent) 
                {
                    //super.onActivityResult(requestCode, resultCode, intent);if (requestCode == 0) {
                        if (resultCode == RESULT_OK) {

                        } elseif (resultCode == RESULT_CANCELED) {

                        }
                    }
                }


            @OverridepublicbooleanonCreateOptionsMenu(Menu menu) {
                // Inflate the menu; this adds items to the action bar if it is present.
                getMenuInflater().inflate(R.menu.main, menu);
                returntrue;
            }

        }

Edit:Change your onCreate method with this one and check. Hope it works.

Post a Comment for "Button No Longer Does What It Is Supposed To Do"