In Sencha touch if I use navigation view i can get back button. This is pretty fine.
But what if user hit device backbutton? it is direct exiting the applicaiton. In my requirement it should not exit the application it has to go back to previous screen.How can i do this?.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
You can handle hardware back button like this:
I didn't find the instructions on the history support page that useful when trying to do this; I couldn't see anyway to use routes when dealing with a navigation view which can have a large stack of views on it at anytime.
If you just want the back button to work though, you can use the
popstate
andpushstate
functions (see https://developer.mozilla.org/en-US/docs/DOM/Manipulating_the_browser_history for a reference). The idea is that youpush
a state when adding a view andpop
it off when removing one. The physical back button on an Android phone, or the back button on a desktop browser effectively callshistory.back()
; so all you need to do is ensure that pressing the back button on the titlebar does the same, and it is that which triggers the nav view to pop.To make use it work in Sencha Touch, I add the following to the main controller:
In refs I have references to the
main
view (an instance ofExt.navigation.View
) and to its titlebar, from which you can hook onto the event of the back button e.g.:I attach the following functions via the
control
config object..These are defined as:
I then attach a function to execute when the state is popped via the init function of..
Now, pressing back on the titlebar, executes
history.back()
, this in turn fires thepopstate
event which then causes the main view to pop.If you want to see this working on a real application, there is a (v. basic!) property finder app using this technique on github here.