I have a private onClickListener class with a switch statement for everybutton
Some buttons, like returning to my main menu, allow me to have an Intent, because the main menu is called in the defining of the class in the onCreate() like so:
//return to main menu
case R.id.return_main:
Intent intent = new Intent(main.this, main.class);
startActivity(intent);
finish();
But how do I create an activity (on a button call) when I want to access a method that is also within the class I am in?
I can't do:
case R.id.snap_another:
Intent intentCam = new Intent(main.openCamera(), main.class);
startActivity(intentCam);
finish();
Basically, I need to be able to kil开发者_运维问答l the last layout the user was shown when he called openCamera() the first time. Can I finish(); methods in a case or do I have to somehow make this an intent?
You don't need to call an intent for running methods from parent class.
simply call that method like this
main.this.openCamera();
and you can use the finish()
call also if you want to exit the current activity
精彩评论