Live Thư mục Hoạt động
các thư mục Live được định nghĩa bằng một Intent trả lại như là kết quả của một hoạt động (thông thường là từ bên trong xử lý onCreate).
Sử dụng phương pháp SetData của Ý định để xác định URI của các nhà cung cấp nội dung cung cấp các dữ liệu (với chiếu thích hợp áp dụng .), như mô tả trong phần trước
Bạn có thể cấu hình Ý định hơn nữa bằng cách sử dụng một loạt các tính năng bổ sung như sau:
. ^ LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE - Chỉ định các chế độ hiển thị sử dụng
này có thể là LiveFolders.DISPLAY_MODE_LIST hoặc LiveFolders.DISPLAY_MODE_ GRID để hiển thị Thư mục Live của bạn như là một danh sách hoặc lưới, tương ứng.
^ LiveFolders.EXTRA_LIVE_FOLDER_ICON - Cung cấp một nguồn tài nguyên có thể vẽ được sẽ được sử dụng như là biểu tượng màn hình chủ, đại diện cho thư mục trực tiếp khi nó chưa được mở.
^ LiveFolders.EXTRA_LIVE_FOLDER_NAME - Cung cấp một mô tả tên để sử dụng với các biểu tượng mô tả ở trên để đại diện cho các thư mục trực tiếp trên màn hình chủ khi nó chưa được mở.
Liệt 14-30 cho thấy các ghi đè onCreate phương pháp của một Hoạt động sử dụng để tạo ra một thư mục Live. Sau Live Ý định nghĩa thư mục được xây dựng, nó được thiết lập như là kết quả Hoạt động sử dụng setResult, và các Hoạt động được đóng lại với một cuộc gọi để kết thúc.
// Return Folder Ý định Live như là một kết quả. setResult (RESULT_OK, mục đích);
}
khác
setResult (RESULT_CANCELED);
kết thúc ();
}
đoạn mã PA4AD_Ch14_MyLiveFolder / src / MyLiveFolder.java
Bạn cũng có thể cung cấp hỗ trợ cho việc lựa chọn các mục trong Folder Live.
Bằng cách thêm một LiveFolders.EXTRA_LlVE_FOLDER_BASE_lNTENT bổ sung cho các Ý định trở lại, bạn có thể chỉ định một Ý định cơ sở để bắn khi một mục Sống Thư mục được chọn. Khi giá trị này được thiết lập, chọn một thư mục mục Live sẽ dẫn đến startActivity được gọi với Ý định cơ sở quy định sử dụng như các tham số Intent.
Thực hành tốt nhất (như thể hiện trong Liệt kê 14-31) là để thiết lập các thông số dữ liệu của Ý định này để các cơ sở URI của các nhà cung cấp nội dung đó là cung cấp dữ liệu Live Thư mục của. Trong những trường hợp như Live thư mục sẽ tự động thêm các giá trị được lưu trữ trong cột _id của mục được chọn để giá trị dữ liệu của Intent.
đang được dịch, vui lòng đợi..