2

我正在开发一个自定义联系人应用程序。我从 Github 阅读了默认的联系人应用程序源,但我并不完全理解。1,据我所知,如果意图的动作相等,将调用 ContactsSearchActivity

com.android.contacts.action.FILTER_CONTACTS(完整清单

  <!-- The contacts search/filter UI -->
    <activity android:name="ContactsListActivity$ContactsSearchActivity"
        android:theme="@style/ContactsSearchTheme"
        android:windowSoftInputMode="stateAlwaysVisible|adjustPan"
    >
        <intent-filter>
            <action android:name="com.android.contacts.action.FILTER_CONTACTS" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="vnd.android.cursor.dir/contact" android:host="com.android.contacts" />
        </intent-filter>
    </activity>

但是 ContactsSearchActivity 没有代码。

public class ContactsListActivity extends ListActivity implements View.OnCreateContextMenuListener,
        View.OnClickListener, View.OnKeyListener, TextWatcher, TextView.OnEditorActionListener,
        OnFocusChangeListener, OnTouchListener {

        public static class ContactsSearchActivity extends ContactsListActivity {

    }

所以我不明白是否调用了 ContactsSearchActivity。(完整源代码

2、二是关于搜索界面。我知道有哪些活动

<meta-data android:name="android.app.searchable"
                android:resource="@xml/searchable"

是活动句柄查询和显示结果。并且启用了 android:name="android.app.default_searchable" 的搜索 + 指向搜索句柄活动。

<meta-data
            android:name="android.app.default_searchable"
            android:value=".ContactsListActivity" />

但同样在 Contacts 的清单中,SearchResultsActivity是从 ContactsListActivity 扩展的空类。

<!-- The contacts search/filter UI -->
        <activity android:name="SearchResultsActivity"
            android:theme="@style/TallTitleBarTheme"
            android:label="@string/contactsList"
        >
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

            <meta-data android:name="android.app.searchable"
                android:resource="@xml/searchable"
            />
        </activity>

<meta-data
                android:name="android.app.default_searchable"
                android:value=".ContactsListActivity" /> 

在应用程序标签而不是活动标签(链接)中。我想了解这些,因为我不知道如何显示它 自定义搜索而不是这

在此先感谢,很抱歉问了很长的问题。

编辑:第 1 部分没关系。在第 2 部分中,我想在按下搜索按钮时显示自定义对话框,但现在我只能将结果存档在第二张图像中。

4

2 回答 2

1

这意味着一切都由ContactListActivity.

看一下那个onCreate方法,它读取传入的 Intent 以确定如何显示结果。这没什么特别的,因为许多 Android 应用程序都以这种方式工作。

于 2012-06-15T02:55:11.243 回答
0

我更改了我的代码并实现了我的自定义搜索对话框。

于 2012-06-29T10:23:57.243 回答