在android中创建自定义搜索(在布局中插入搜索小部件)

在android中创建自定义搜索(在布局中插入搜索小部件),android,widget,Android,Widget,如何在android应用程序布局中创建自定义搜索 我可以使用“活动”窗口顶部显示的“搜索”对话框,但我希望类似于此处的图像: 如果有样本代码,我将不胜感激 多谢各位 对不起,我的英语太差了。在res文件夹中做一个搜索布局,如下所示 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

如何在android应用程序布局中创建自定义搜索

我可以使用“活动”窗口顶部显示的“搜索”对话框,但我希望类似于此处的图像:

如果有样本代码,我将不胜感激

多谢各位


对不起,我的英语太差了。

在res文件夹中做一个搜索布局,如下所示

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@android:color/white" >

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/white">

            <EditText
                    android:id="@+id/searchText"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"/>

            <Button
                    android:id="@+id/searchButton"
                    android:text="Search"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:onClick="search"/>

        </LinearLayout>

        <ListView
            android:id="@android:id/list"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@android:color/white"/>

</LinearLayout>

在res文件夹中创建搜索布局,如下所示

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@android:color/white" >

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/white">

            <EditText
                    android:id="@+id/searchText"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"/>

            <Button
                    android:id="@+id/searchButton"
                    android:text="Search"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:onClick="search"/>

        </LinearLayout>

        <ListView
            android:id="@android:id/list"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@android:color/white"/>

</LinearLayout>


@hey Joseph您可以参考此链接在android中进行搜索@hey Joseph您可以参考此链接在android中进行搜索