TAILIEUCHUNG - Lập trình Androi part 29

Tài nguyên có bit tĩnh của thông tin được tổ chức bên ngoài các mã nguồn Java. Bạn đã thấy một loại tài nguyên bố trí thường xuyên trong các ví dụ trong cuốn sách này. Như bạn sẽ học trong chương này, có rất nhiều loại tài nguyên khác, chẳng hạn như hình ảnh và chuỗi, mà bạn có thể tận dụng trong các ứng dụng Android của bạn. | Chapter Working with Resources Resources are static bits of information held outside the Java source code. You have seen one type of resource the layout frequently in the examples in this book. As you ll learn in this chapter there are many other types of resources such as images and strings that you can take advantage of in your Android applications. The Resource Lineup Resources are stored as files under the res directory in your Android project layout. With the exception of raw resources res raw all the other types of resources are parsed for you either by the Android packaging system or by the Android system on the device or emulator. So for example when you lay out an activity s UI via a layout resource res layout you do not need to parse the layout XML yourself Android handles that for you. In addition to layout resources introduced in Chapter 4 and animation resources introduced in Chapter 9 several other types of resources are available including the following Images res drawable for putting static icons or other pictures in a user interface Raw res raw for arbitrary files that have meaning to your application but not necessarily to Android frameworks Strings colors arrays and dimensions res values to both give these sorts of constants symbolic names and to keep them separate from the rest of the code . for internationalization and localization XML res xml for static XML files containing your own data and structure 197 CHAPTER 20 Working with Resources String Theory Keeping your labels and other bits of text outside the main source code of your application is generally considered to be a very good idea. In particular it helps with internationalization and localization covered in the Different Strokes for Different Folks section later in this chapter. Even if you are not going to translate your strings to other languages it is easier to make corrections if all the strings are in one spot instead of scattered throughout your source code. Android supports .

Đã 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.