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、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" /> 

application タグではなく activity タグ ( link )。カスタム検索代わりにこれを表示する方法がわからないので、これらを理解したい これ

事前に感謝し、長い質問で申し訳ありません.

編集:part1で大丈夫です。パート 2 では、検索ボタンを押したときにカスタム ダイアログを表示したいのですが、結果を 2 番目の画像にしかアーカイブできません。

4

2 に答える 2

1

つまり、すべてが のコードによって処理されContactListActivityます。

そのメソッドを見てみましょうonCreate。着信インテントを読み取って、結果を表示する方法を決定します。多くの Android アプリがこのように動作しているため、それほど特別なことではありません。

于 2012-06-15T02:55:11.243 に答える
0

コードを変更して、カスタム検索ダイアログを実現します。

于 2012-06-29T10:23:57.243 に答える