In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will give you a detailed explanation on how to carry out AIR for Android development, the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Adobe has released mobile AIR for some time, but the UI and controls of mobile devices are completely different from those of PC, resulting in very few mobile device programs that really use AIR technology. Some time ago, Adobe finally released Flex SDK "Hero" (that is, the previous Slider), which includes mobile UI components. Although it only supports Android systems, we can see that more and more programs are developed using AIR technology in the electronic market. This article will take MP3 radio station as an example to introduce some methods and experiences of using Flex Hero to develop mobile AIR applications.
Introduce mobile applications
There is an important concept in the mobile program interface: the screen, as shown below.
In the MP3 radio program, the selection interface and the playback interface are two "screens". On the PC side, these operations can be done together, but they cannot be crammed into one interface because of the screen size of the mobile device. So after we have selected the station, the whole screen will be converted to the radio playback interface. View in Flex Hero
In Flex "Hero", the concept of "screen" is called View. The core classes for mobile platforms in hero are as follows:
Among them, MobileApplication is equivalent to the desktop version of Application, is the container of the whole program. ViewNavigator manages the display and switching of each View, and also includes the top control bar ActionBar.
How ViewNavigator handles view switching:
Navigator.pushView (view,data,transition=null); navigator.popView (transition=null)
The ViewNavigator.pushView method is used to switch to a new view, for example, when the user selects a channel on the channel list page, we can execute the
Navigator.pushView (RadioPlay, {channel_item:channelList.selectedItem})
In that case, you switch to the RadioPlay view. At this point, if the user presses the back button on the android, the Flex framework automatically performs the navigator.popView operation, which returns to the previous view. Of course, we can also capture this keyboard event and execute the custom code. Data-driven view
This.addEventListener (KeyboardEvent.KEY_UP,function (e:KeyboardEvent) {if (e.keyCode = = Keyboard.BACK) {e.stopPropagation (); / other operations, such as storing data, etc. / / other operations completed navigator.popView ();}})
When switching views, Flex destroys the UI of the previous view by default (you can avoid destruction by setting destructionPolicy= "none"). In this way, when we go back to the previous view, we will lose the previous UI state. For example, the selected state View of the channel list contains an attribute data, and the second parameter data will be assigned to this attribute when the developer uses the pushView method. Every time the user presses the back button on the fuselage, the Flex framework executes the popView method to automatically restore the history, and the last data property is also put back into the constructor of View. As you can see, if we need to save all the states of the current view when the interface is switched, the relevant code is as follows:
This.addEventListener (FlexEvent.VIEW_DEACTIVATE,saveState); private function saveState (event:Event): void {this.data.selection = channelList.selectedIndex; this.data.scrollPosition = channelList.dataGroup.verticalScrollPosition;}
In this way, when we leave the channel list page, we will record the selected status of the current list, and when we redisplay the View, we can restore it:
Private function restoreState (): void {if (! data) {data = new Object ();} if (data.selection) {channelList.selectedIndex = data.selection;} if (data.scrollPosition) {channelList.dataGroup.verticalScrollPosition = this.data.scrollPosition;}}
Optimization skills and points for attention
AIR on Android does not exit automatically, that is, when the user presses the home key or goes back to the home screen, the AIR program is still running. For an application like radio, it makes sense to run in the background, but if you want to step back and exit like a traditional program, you need to do some extra work:
If (Capabilities.cpuArchitecture== "ARM") {NativeApplication.nativeApplication.addEventListener (Event.DEACTIVATE, handleDeactivate, false, 0, true);} private function handleDeactivate (event:Event): void {NativeApplication.nativeApplication.exit ();}
AIR animation is relatively inefficient on some devices, so we can set cacheAsBitmapMatrix=true for the moving symbol and give this symbol to GPU hardware rendering. This property is almost exactly the same as the desktop version of cacheAsBitmap, and setting this property can greatly speed up animation efficiency for display objects that need to pan and zoom.
On how to develop AIR for Android to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.