TAILIEUCHUNG - Lập trình Androi part 12

Danh sách xếp hạng trong các công trình phần trước, nhưng thực hiện nó đã rất buồn tẻ. Tệ hơn, nhiều tedium rằng sẽ không thể tái sử dụng, trừ trường hợp rất hạn chế. Chúng tôi có thể làm tốt hơn. | CHAPTER 8 Getting Fancy with Lists .And Checking It Twice The rating list in the previous section works but implementing it was very tedious. Worse much of that tedium would not be reusable except in very limited circumstances. We can do better. What we would really like is to be able to create a layout like this xml version encoding utf-8 xmlns android http apk res android android id @android id list android layout_width fill_parent android layout_height fill_parent android drawSelectorOnTop false In our code almost all of the logic that might have referred to a ListView before just works with the RateListView we put in the layout String items lorem ipsum dolor sit amet consectetuer adipiscing elit morbi vel ligula vitae arcu aliquet mollis etiam vel erat placerat ante porttitor sodales pellentesque augue purus Override public void onCreate Bundle icicle super. onCreate icicle setContentView setListAdapter new ArrayAdapter String this items Where things get a wee bit challenging is when you stop and realize that in everything up to this point in this chapter we never actually changed the ListView itself. All our work was with the adapters overriding getView and inflating our own rows. So if we want RateListView to take in any ordinary ListAdapter and just work putting rating bars on the rows as needed we are going to need to do some fancy footwork. Specifically we need to wrap the raw ListAdapter in some other ListAdapter that knows how to put the rating bars on the rows and track the state of those rating bars. First we need to establish the pattern of one ListAdapter augmenting another. Here is the code for AdapterWrapper which takes a ListAdapter and delegates all of the interface s methods to the delegate from the FancyLists RateListView sample project public class AdapterWrapper implements ListAdapter ListAdapter delegate null public

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.