tailieunhanh - Beginning Android PHẦN 8
Java API truyền thống không tồn tại trong Dalvik-ví dụ, có thể có các công cụ ẩn bên trong BeanShell hoặc tiện ích lọ mà không làm việc trên Android hiện nay. Thứ hai, ngôn ngữ kịch bản mà không JIT chắc chắn sẽ chậm hơn so với biên soạn các ứng dụng Dalvik. Chậm hơn có thể có nghĩa là trì trệ kinh nghiệm người dùng. | 244 CHAPTER 26 HANDLING ROTATION The third possibility for handling rotations therefore is to tell Android that you will handle them completely yourself and that you do not want assistance from the framework. To do this 1. Put an android configChanges entry in your file listing the configuration changes you want to handle yourself versus allowing Android to handle for you. 2. Implement onConfigurationChanged in your Activity which will be called when one of the configuration changes you listed in android configChanges occurs. Now for any configuration change you want you can bypass the whole activity-destruction process and simply get a callback letting you know of the change. To see this in action turn to the Rotation RotationThree sample application. Once again our layouts are the same so the application looks the same as the preceding two samples. However the Java code is significantly different because we are no longer concerned with saving our state but rather with updating our UI to deal with the layout. But first we need to make a small change to our manifest xml version encoding utf-8 manifest xmlns android http apk res android package android versionCode 1 android versionName application android label @string app_name activity android name .RotationThreeDemo android label @string app_name android configChanges keyboardHidden orientation intent-filter action android name category android name intent-filter activity application manifest Here we state that we will handle keyboardHidden and orientation configuration changes ourselves. This covers us for any cause of the rotation whether it is a sliding keyboard or a physical rotation. Note that this is set on the activity not the application if you have several activities you will need to decide for each which of the tactics outlined in this chapter you wish to .
đang nạp các trang xem trước