Đây là một khả năng.
Xác định bố cục hàng đề xuất truy vấn, ví dụ: R.layout.li_query_suggestion, trông như thế này:
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:id="@android:id/text1"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="center_vertical"
android:minHeight="56dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="@android:color/black"
tools:text="Blah blah blah"/>
ý rằng màu nền là màu trắng và màu chữ là màu đen. Bạn có thể, tất nhiên, thay đổi các giá trị này.
Sau đó, trong bộ điều hợp con trỏ, hãy chỉ định bố cục bạn đã tạo làm bố cục hàng. Ví dụ:
CursorAdapter suggestionAdapter = new SimpleCursorAdapter(
getActivity(),
R.layout.li_query_suggestion,
null,
new String[]{"name"},
new int[]{android.R.id.text1},
0);
này sẽ cung cấp cho bạn cái gì đó trông giống như sau:
Just FYI, chủ đề hiện tại của tôi trông như thế này:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/light_blue_500</item>
<item name="colorPrimaryDark">@color/light_blue_700</item>
<item name="colorAccent">@color/pink_a200</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="searchViewStyle">@style/CustomSearchView</item>
</style>
Nguồn
2014-12-03 19:39:27
Bạn đã thử đề nghị Chris Banes'? http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html. Tìm tiêu đề phần SearchView Widget. –