Using XML-Based Layouts While it is technically possible to create and dịch - Using XML-Based Layouts While it is technically possible to create and Việt làm thế nào để nói

Using XML-Based Layouts While it is

Using XML-Based Layouts
While it is technically possible to create andattach widgets to your activity purely
through Java code, as we did in the preceding chapter, the more common approach is
to use an XML-based layout file. Dynamic instantiation of widgets is reserved for more
complicated scenarios, where the widgets are not known at compile time (e.g.,
populating a column of radio buttons based on data retrieved from the Internet).
With that in mind, it’s time to break out the XML and learn how to lay out Android activity
views that way.
What Is an XML-Based Layout?
As the name suggests, an XML-based layout is a specification of widgets’ relationships
to each other—and to containers—encoded inXML format. Specifically, Android
considers XML-based layouts to be resources, andas such, layout files are stored in the
reslayoutdirectory inside your Android project.
Each XML file contains a tree of elements specifying a layout of widgets and containers
that make up one View. The attributes of the XML elements are properties, describing
how a widget should look or how a container should behave. For example, if a Button
element has an attribute value of android:textStyle = "bold", that means that the text
appearing on the face of the button should be rendered ina boldface font style.
Android’s SDK ships with a tool (aapt) that uses the layouts. This tool should be
automatically invoked by your Android tool chain (e.g., Eclipse or Ant’s build.xml). Of
particular importance to you as a developer is that aaptgenerates the R.javasource file
within your project’s gendirectory, allowing you to access layouts and widgets within
those layouts directly from your Java code, aswill be demonstrated later in this chapter.
1774/5000
Từ: Anh
Sang: Việt
Kết quả (Việt) 1: [Sao chép]
Sao chép!
Bằng cách sử dụng bố trí XML-Based
trong khi nó là kỹ thuật có thể để tạo ra các andattach widget để hoạt động của bạn hoàn toàn
thông qua mã Java, như chúng tôi đã làm ở các chương trước, cách tiếp cận phổ biến hơn là
để sử dụng một tập tin XML dựa trên giao diện. Instantiation động vật được dành riêng để biết thêm
phức tạp kịch bản, nơi các vật dụng không được biết đến tại thời gian biên dịch (ví dụ:
Populating một cột nút radio dựa trên dữ liệu Lấy từ Internet).
Với ý nghĩ đó, nó là thời gian để thoát ra khỏi các XML và tìm hiểu làm thế nào để lay ra hoạt động Android
xem như vậy.
Những gì là một giao diện dựa trên XML?
Như tên cho thấy, một giao diện dựa trên XML là một đặc điểm kỹ thuật của mối quan hệ vật dụng
với nhau — và container-định dạng mã hóa inXML. Cụ thể, Android
xem xét XML dựa trên bố trí để là nguồn tài nguyên, andas như vậy, bố trí các tập tin được lưu trữ trong các
reslayoutdirectory bên trong dự án Android của bạn.
Mỗi tệp tin XML chứa một cây yếu tố xác định một cách bố trí widget và các thùng chứa
tạo nên một giao diện. Các thuộc tính của các yếu tố XML là tài sản, mô tả
cách một widget nên xem xét hoặc làm thế nào một container nên cư xử. Ví dụ, nếu một nút
nguyên tố có một giá trị thuộc tính của android: textStyle = "đậm", điều đó có nghĩa rằng các văn bản
xuất hiện trên khuôn mặt của nút nên được kết xuất kiểu phông đậm ina.
Android SDK tàu với một công cụ (aapt) sử dụng bố trí. Công cụ này nên
tự động kích hoạt bởi chuỗi công cụ Android của bạn (ví dụ như, Nhật thực hoặc kiến của build.xml). Của
tầm quan trọng đặc biệt cho bạn như là một nhà phát triển là mà aaptgenerates các tập tin R.javasource
trong dự án của bạn gendirectory, cho phép bạn để bố trí truy cập và các vật dụng trong
những bố trí trực tiếp từ của bạn mã Java, aswill được chứng minh sau đó trong chương này.
đang được dịch, vui lòng đợi..
Kết quả (Việt) 2:[Sao chép]
Sao chép!
Using XML-Based Layouts
While it is technically possible to create andattach widgets to your activity purely
through Java code, as we did in the preceding chapter, the more common approach is
to use an XML-based layout file. Dynamic instantiation of widgets is reserved for more
complicated scenarios, where the widgets are not known at compile time (e.g.,
populating a column of radio buttons based on data retrieved from the Internet).
With that in mind, it’s time to break out the XML and learn how to lay out Android activity
views that way.
What Is an XML-Based Layout?
As the name suggests, an XML-based layout is a specification of widgets’ relationships
to each other—and to containers—encoded inXML format. Specifically, Android
considers XML-based layouts to be resources, andas such, layout files are stored in the
reslayoutdirectory inside your Android project.
Each XML file contains a tree of elements specifying a layout of widgets and containers
that make up one View. The attributes of the XML elements are properties, describing
how a widget should look or how a container should behave. For example, if a Button
element has an attribute value of android:textStyle = "bold", that means that the text
appearing on the face of the button should be rendered ina boldface font style.
Android’s SDK ships with a tool (aapt) that uses the layouts. This tool should be
automatically invoked by your Android tool chain (e.g., Eclipse or Ant’s build.xml). Of
particular importance to you as a developer is that aaptgenerates the R.javasource file
within your project’s gendirectory, allowing you to access layouts and widgets within
those layouts directly from your Java code, aswill be demonstrated later in this chapter.
đang được dịch, vui lòng đợi..
 
Các ngôn ngữ khác
Hỗ trợ công cụ dịch thuật: Albania, Amharic, Anh, Armenia, Azerbaijan, Ba Lan, Ba Tư, Bantu, Basque, Belarus, Bengal, Bosnia, Bulgaria, Bồ Đào Nha, Catalan, Cebuano, Chichewa, Corsi, Creole (Haiti), Croatia, Do Thái, Estonia, Filipino, Frisia, Gael Scotland, Galicia, George, Gujarat, Hausa, Hawaii, Hindi, Hmong, Hungary, Hy Lạp, Hà Lan, Hà Lan (Nam Phi), Hàn, Iceland, Igbo, Ireland, Java, Kannada, Kazakh, Khmer, Kinyarwanda, Klingon, Kurd, Kyrgyz, Latinh, Latvia, Litva, Luxembourg, Lào, Macedonia, Malagasy, Malayalam, Malta, Maori, Marathi, Myanmar, Mã Lai, Mông Cổ, Na Uy, Nepal, Nga, Nhật, Odia (Oriya), Pashto, Pháp, Phát hiện ngôn ngữ, Phần Lan, Punjab, Quốc tế ngữ, Rumani, Samoa, Serbia, Sesotho, Shona, Sindhi, Sinhala, Slovak, Slovenia, Somali, Sunda, Swahili, Séc, Tajik, Tamil, Tatar, Telugu, Thái, Thổ Nhĩ Kỳ, Thụy Điển, Tiếng Indonesia, Tiếng Ý, Trung, Trung (Phồn thể), Turkmen, Tây Ban Nha, Ukraina, Urdu, Uyghur, Uzbek, Việt, Xứ Wales, Yiddish, Yoruba, Zulu, Đan Mạch, Đức, Ả Rập, dịch ngôn ngữ.

Copyright ©2025 I Love Translation. All reserved.

E-mail: ilovetranslation@live.com