简体   繁体   中英

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?

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

If sample codes are available, I will appreciate so much.

Thank you.

Sorry about my english.

make a search layout in res folder as

<?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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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