TAILIEUCHUNG - Lập trình Androi part 05

Mỗi bộ công cụ GUI có một số vật dụng cơ bản: các lĩnh vực, nhãn, các nút, và như vậy. Android của bộ công cụ là không có khác nhau trong phạm vi, và các vật dụng cơ bản sẽ cung cấp một giới thiệu tốt để làm thế nào vật dụng làm việc trong các hoạt động Android. | Chapter Employing Basic Widgets Every GUI toolkit has some basic widgets fields labels buttons and so on. Android s toolkit is no different in scope and the basic widgets will provide a good introduction to how widgets work in Android activities. Assigning Labels The simplest widget is the label referred to in Android as a TextView. As in most GUI toolkits labels are bits of text that cannot be edited directly by users. Typically they are used to identify adjacent widgets . a Name label next to a field where you fill in a name . In Java you can create a label by creating a TextView instance. More commonly though you will create labels in XML layout files by adding a TextView element to the layout with an android text property to set the value of the label itself. If you need to swap labels based on certain criteria such as internationalization you may wish to use a resource reference in the XML instead as will be described in Chapter 20. TextView has numerous other properties of relevance for labels such as the following android typeface Sets the typeface to use for the label . monospace . android textStyle Indicates that the typeface should be made bold bold italic italic or bold and italic bold_italic . android textColor Sets the color of the label s text in RGB hex format . FF0000 for red . For example in the Basic Label project you will find the following layout file xml version encoding utf-8 TextView xmlns android http apk res android android layout_width fill_parent android layout_height wrap_content android text You were expecting something profound 29 CHAPTER 5 Employing Basic Widgets Just that layout alone with the stub Java source provided by Android s project builder . android create project gives you the demo shown in Figure 5-1. Figure 5-1. The LabelDemo sample application Button Button Who s Got the Button You have already seen the use of the Button widget in the previous two chapters. As it turns out Button is a .

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.