TAILIEUCHUNG - Lập trình Androi part 21

Không phải mọi tương tác với người dùng Android sẽ được gọn gàng và containable trong hoạt động bao gồm các quan điểm. Lỗi sẽ cắt lên. Bối cảnh nhiệm vụ có thể mất nhiều thời gian hơn dự kiến. Một cái gì đó không đồng bộ có thể xảy ra, như một thông điệp gửi đến. Trong những trường hợp khác, bạn có thể cần phải giao tiếp với người sử dụng bên ngoài giới hạn của giao diện truyền thống | Chapter Showing Pop-Up Messages Sometimes your activity or other piece of Android code will need to speak up. Not every interaction with Android users will be tidy and containable in activities composed of views. Errors will crop up. Background tasks may take much longer than expected. Something asynchronous may occur such as an incoming message. In these and other cases you may need to communicate with the user outside the bounds of the traditional UI. Of course this is nothing new. Error messages in the form of dialog boxes have been around for a very long time. More subtle indicators also exist from task tray icons to bouncing dock icons to vibrating cell phones. Android has quite a few systems for letting you alert your users outside the bounds of an Activity-based UI. One notifications is tied heavily into intents and services and as such is covered in Chapter 31. In this chapter you will learn about two means of raising pop-up messages toasts and alerts. Raising Toasts A Toast is a transient message meaning that it displays and disappears on its own without user interaction. Moreover it does not take focus away from the currently active Activity so if the user is busy writing the next Great Programming Guide his keystrokes will not be eaten by the message. Since a Toast is transient you have no way of knowing if the user even notices it. You get no acknowledgment nor does the message stick around for a long time to pester the user. Hence the Toast is mostly for advisory messages such as indicating a long-running background task is completed the battery has dropped to a low but not too low level and so on. 149 CHAPTER 14 Showing Pop-Up Messages Making a Toast is fairly easy. The Toast class offers a static makeText that accepts a String or string resource ID and returns a Toast instance. The makeText method also needs the Activity or other Context plus a duration. The duration is expressed in the form of the LENGTH_SHORT or LENGTH_LONG constants to indicate on

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.