Hy vọng đây không phải là một câu hỏi tồi, tuy nhiên tôi đã tìm kiếm qua S.O. và không thể tìm ra câu trả lời.Cách tạo số lần xem văn bản thay đổi trong android
Tôi đang tạo một ứng dụng Android chủ yếu là đồng hồ báo thức. Tôi muốn hoạt động chính hiển thị tất cả các báo thức đã được tạo cùng với một số thông tin về báo thức. Câu hỏi của tôi về việc này là cách tạo một số lượt xem văn bản nhất định dựa trên số lượng báo thức đã được tạo. Ví dụ: nếu người dùng đã tạo (và không bị xóa) 5 báo thức, làm cách nào để hiển thị 5 lần xem văn bản thay vì chỉ một số lượt xem văn bản được mã hóa cứng? Sau đây là nguyên mẫu được mã hóa khủng khiếp của tôi để kiểm tra chức năng (ngoài việc gác máy này).
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Launch" >
<ScrollView
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:orientation = "vertical"
android:layout_width="fill_parent"
android:layout_height="75dp"
android:text="Time"/>
<View
android:layout_width="fill_parent"
android:layout_height="0.2dp"
android:id="@+id/separator"
android:visibility="visible"
android:background="@android:color/darker_gray"/>
<TextView
android:orientation = "vertical"
android:layout_width="fill_parent"
android:layout_height="75dp"
android:text="Time"/>
<View
android:layout_width="fill_parent"
android:layout_height="0.2dp"
android:id="@+id/separator"
android:visibility="visible"
android:background="@android:color/darker_gray"/>
<TextView
android:orientation = "vertical"
android:layout_width="fill_parent"
android:layout_height="75dp"
android:text="Time"/>
<View
android:layout_width="fill_parent"
android:layout_height="0.2dp"
android:id="@+id/separator"
android:visibility="visible"
android:background="@android:color/darker_gray"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
Như bạn thấy, chỉ có ba chế độ xem văn bản được mã hóa cứng thay vì số lần xem văn bản do người dùng tạo.
Một lần nữa, tôi hy vọng điều này không quá sâu sắc về câu hỏi hoặc câu hỏi có câu trả lời được đăng ở nơi khác nhưng tôi đã tìm kiếm và không thể tìm thấy bất kỳ điều gì.
Cảm ơn trước!
Bạn sẽ cần phải làm điều này programatically, không chỉ thông qua xml. –
bạn có thể sử dụng listview và cursoradapter cho rằng thay vì scrollview.I có nghĩa là nếu bạn lưu báo động trong db sau đó bạn có thể sử dụng một listview với cursoradapter cho báo động hiển thị –
Xem nếu câu trả lời của tôi giúp bạn ra ngoài. Vì bạn mới làm quen với SO, hãy xem [tour] (http://stackoverflow.com/about). –