1
我要實現我的設置菜單看起來像這樣如何創建每行可點擊的設置菜單?
現在我開始用一個相對佈局,但我不知道這是解決的最佳方式,也不知如何在其中添加水平線。我想我的每個textviews都有一個背景圖片。
對於每一行,都會有一個新的視圖顯示出來。 有沒有更好的方法?
這是到目前爲止我的代碼,而無需水平線
<!-- HEADER -->
<include
android:id="@+id/top_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
layout="@layout/header" />
<!-- FOOTER -->
<LinearLayout
android:id="@+id/bottom_footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
<!-- menu bar -->
<include layout="@layout/footer" />
</LinearLayout>
<LinearLayout
android:id="@+id/settings_screen"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/bottom_footer"
android:layout_below="@id/top_header"
android:layout_marginLeft="@dimen/marginLeft"
android:orientation="vertical" >
<TextView
android:id="@+id/account_info"
android:layout_width="278dp"
android:layout_height="wrap_content"
android:text="@string/acount_info"
android:background="@null"
android:onClick="startAccountInfoAction"
android:clickable="true"
/>
<TextView
android:id="@+id/Statistic"
android:layout_width="278dp"
android:layout_height="wrap_content"
android:text="@string/statistic" />
<TextView
android:id="@+id/Contact"
android:layout_width="278dp"
android:layout_height="wrap_content"
android:text="@string/contact" />
<TextView
android:id="@+id/open_jobs_label"
android:layout_width="278dp"
android:layout_height="wrap_content"
android:text="@string/open_jobs_label" />
<ImageButton
android:id="@+id/btn_sendData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@null"
android:onClick="startSendDataAction"
android:src="@drawable/restart_upload_blau" />
<TextView
android:id="@+id/send_error_label"
android:layout_width="278dp"
android:layout_height="wrap_content"
android:text="@string/send_error_label" />
<ImageButton
android:id="@+id/btn_sendError"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@null"
android:onClick="startSendErrorAction"
android:src="@drawable/error_srs_blau" />
</LinearLayout>
我想你可以用'PrefernceActivity'來做到這一點。這種方法更容易和更原生的android。因此,您的設置菜單將顯示爲典型的Android設置菜單。告訴我這是否對你有好處。我可以幫助你。 – Dulanga