简体   繁体   English

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

[英]creating a custom search in android (inserting a search widget in the layout)

How can I create a custom search within my android app layout? 如何在Android应用布局中创建自定义搜索?

I am able to use the search dialog that appears at the top of the activity window but I would like something similar to the image here: 我可以使用显示在活动窗口顶部的搜索对话框,但我想要类似于此处的图像:

自定义搜索视图 http://img5.imageshack.us/img5/1298/customsearch.gif http://img5.imageshack.us/img5/1298/customsearch.gif

If sample codes are available, I will appreciate so much. 如果有示例代码,我将非常感谢。

Thank you. 谢谢。

Sorry about my english. 对不起,我的英语。

make a search layout in res folder as 在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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM