开发者

Android OnTabChangingListener

The TabHost widget has a setOnTabChangedListe开发者_StackOverflowner() method to run code when the tab changes, but I need to run code before the tab changes, in order to validate the data entered. Is this possible? I was thinking about using a click listener but it seems like it would be fiddly to get it to detect clicks on items, and I'm still not sure how you'd cancel changing the tab and show a message.


I do not know if you can check something before the tab is changed, however there is an alternative. when the tab is changed, perform your checks, and if the data entered isnt valid, change the content view of the tab to display the message, or make it empty and pop a message box explaining the error. from there you can set up the dialog so when it's closed it calls setCurrentTab(int index) to return to the tab that is prompting for input.

does that help?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜