back

back button callback in navigationController in iOS

泄露秘密 提交于 2019-11-27 10:18:51
I have pushed a view onto the navigation controller and when I press the back button it goes to the previous view automatically. I want to do a few things when back button is pressed before popping the view off the stack. Which is the back button callback function? ymutlu William Jockusch's answer solve this problem with easy trick. -(void) viewWillDisappear:(BOOL)animated { if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) { // back button was pressed. We know this is true because self is no longer // in the navigation stack. } [super viewWillDisappear:animated];

EditText with soft keyboard and “Back” button

主宰稳场 提交于 2019-11-27 08:55:58
When I'm using "EditText" I have the virtual keyboard. Pressing first time "Back" button hides the keyboard. Second press invokes "onBackPressed" callback in my activity. OK, but... I have no idea how to hook the very first press. I need to process input data as soon as the virtual keyboard dismissed. Any ideas are welcome. Thanks. Blundell You can override when the keyboard disappears using this method: public boolean onKeyPreIme(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) { // Do your thing here return false; } return super

How to read data from shape/graphics object

半城伤御伤魂 提交于 2019-11-27 08:26:59
问题 I am wondering if it is possible to get the data that is stored in a shape/graphics object in flash using actionscript 3? In my project I would like to be able to draw a shape and then read all the points in that shape into my script. The reason for that is that I need go generate lines from those points that I later can use to check if my characters velocity intersects with any of them. 回答1: You can read all parts of Shape. New feature added to Flash Player 11.6 and AIR 3.6: flash.display

jQuery UI Tabs back button history

空扰寡人 提交于 2019-11-27 07:13:50
Has anyone been able to get jQuery UI Tabs 3(Latest version) working with the back button? I mean if the user hits the back button they should go to the previously visited tab on the page, not a different page. The history plug in sounds like it can work, but i cant seem to make it work with ajax loaded tabs. If anyone has managed to make this work, it would be deeply appreciated, thanks! Justin Hamade I just ran into this as well. Its really easy with the jquery address plugin here http://www.asual.com/jquery/address/ The demo for tabs seemed a bit over complicated. I just did this: $(

Fragment pressing back button

荒凉一梦 提交于 2019-11-27 06:37:33
I am now having an activity containing fragments [1] , [2] , [3] , [4] If pressing buttons , [3] , it can be redirected to [4] I would like to implement the back button as shown follow.. when pressing back at [4] , it return to [3] when pressing back at [3] , it return to [2] when pressing back at [1] , the activity finishes(); When it comes to the current implementation, it finish the activity instead of popping up the Fragment. Would you please tell me what I should do or keep in mind ? @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if( keyCode==KeyEvent.KEYCODE_BACK) {

When I exit an application the sound runs on the background

落花浮王杯 提交于 2019-11-27 06:27:32
问题 I "created" an application and when I go back or I press the home button to exit from the application, the audio from my application is still running! I have to close all running apps to make it stop. How can I stop the audio running when I press the home button? 回答1: Override the onPause() method of all your activities, and turn off/pause/stop the music when it's called. You might want use a boolean flag to check if you're moving within your app, a scenario in which you'd want the music to

How do I kill an Activity when the Back button is pressed?

别等时光非礼了梦想. 提交于 2019-11-27 04:03:12
I got an Activity that when it starts, it loads an image from the internet. In an effort to save memory, when the Activity is left by the back button being pressed, I want the activity to dump all data, that is get rid of all the strings and images that are in it. I figured the best way to do this was to just kill the activity. Well, I can't seem to figure out the callback for when the Back button is pressed. So, I have been trying to use the onPause() and the onStop() callbacks for the task but both ways force close my app. Here is the code: public void onPause() { this.finish(); } public

How to Control Android back stack

时光毁灭记忆、已成空白 提交于 2019-11-27 03:36:12
问题 Lets say I have A->B->C->D->E In android back stack. I want to be able to get back to one of the following: A->B->C A->B A How can I achieve this? Hopefully without forcing back button clicks. 回答1: Using the image and information from the official developers page on Android tasks and back stack you can see that of all other ways to launch an Activity you can ensure such behavior only using the FLAG_ACTIVITY_CLEAR_TOP in your Intent flags. Your regular back button proceeds as: But when you

How to handle Back button with in the dialog?

天大地大妈咪最大 提交于 2019-11-27 03:26:36
I am developing an application that when the button is pressed, it opens a dialog with OK and Cancel buttons. It works fine. When the user presses the back button, I am handling this as follows public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK)) { } return super.onKeyDown(keyCode, event); } But the above method is not called. How can I handle this? dialog.setOnKeyListener(new Dialog.OnKeyListener() { @Override public boolean onKey(DialogInterface arg0, int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (keyCode == KeyEvent.KEYCODE

Android - Confirm app exit with toast

人盡茶涼 提交于 2019-11-27 01:41:12
问题 I'm new to Android development and I want it so when the user presses the back button on the main activity, a toast message appears with a "confirm exit by pressing the back button again" message. How would I do this? This is what I have so far: @Override public void onBackPressed() { // TODO Auto-generated method stub super.onBackPressed(); Toast s = Toast.makeText(getBaseContext(), "Press back again to exit", Toast.LENGTH_LONG); s.show(); wait(); public boolean onBackPressed() { finish(); }