基本上我想在操作栏上获取搜索模式,就像其他应用程序一样。
我不确定如何为图片实现其他应用程序(也许是listview),我将其视为gridview。我使用的过滤器可以很好地根据名称过滤项目。
对于其他任何我忘记发布的内容,请告诉我,我会尽快更新。
grid.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.skypower.myapp.Grid">
<SearchView
android:id="@+id/searchView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignRight="@+id/gridview"
android:layout_marginLeft="10dp"
android:queryHint="hey">
</SearchView>
<GridView
android:id="@+id/gridview"
android:numColumns="4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/searchView1"
android:layout_alignParentLeft="true" >
</GridView>
</RelativeLayout>
的manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.skypower.myapp">
<application
android:allowBackup="true"
android:icon="@mipmap/app_icon"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
<activity android:name="com.skypower.myapp.HeroSelectionActivity"
android:label="hahaha"
android:parentActivityName="com.skypower.myapp.MainActivity" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.support.PARENT_ACTIVITY"
android:value="com.skypower.myapp.MainActivity" />
/>
</activity>
<activity android:name="com.skypower.smartpick.Grid"
android:label="hahaha"
android:parentActivityName="com.skypower.myapp.MainActivity" >
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
<meta-data android:name="android.support.PARENT_ACTIVITY"
android:value="com.skypower.myapp.MainActivity" />
</activity>
</application>
</manifest>
model:xml :(用于每个网格项)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"/>
</RelativeLayout>