Pro Android with Kotlin


Download 5.42 Mb.
Pdf ko'rish
bet144/223
Sana04.11.2023
Hajmi5.42 Mb.
#1746807
1   ...   140   141   142   143   144   145   146   147   ...   223
Bog'liq
@de android telegram Pro Android with Kotlin Developing Modern Mobile

166
CHAPTER 8: APIs
More precisely, to include search facilities inside your app, you have to do this:
1. Provide a searchable configuration as an XML file.
2. Provide an activity that (a) is able to receive a search query, (b) 
performs the search inside your app’s data, and (c) displays the 
search result.
3. Provide a dialog or search widget.
The rest of this section walks through these requirements.
The Searchable Configuration
The searchable configuration is a file named searchable.xml that resides inside the folder
/res/xml of your project. The most basic contents of this file read as follows:

"http://schemas.android.com/apk/res/android"
android:label="@string/app_label"
android:hint="@string/search_hint" >

@string/... points to localized string resources.@string/app_label points to a label and 
should be equal to the name of the label attribute of the  element. The other 
one, @string/search_hint, is the string to be shown inside search fields if nothing has 
been entered yet. It is recommended and should show something like Search
with  being specific to the data your app provides. There are a lot more possible 
attributes and some optional child elements; we will mention some in the following sections. 
For the complete list, please see the online documentation in the “Searchable Configuration” 
section.
The Searchable Activity
For the activity that handles search-related issues inside your app, start with its declaration 
inside AndroidManifest.xml. The activity needs to have a special signature there, as follows:


"android.intent.action.SEARCH" />

android:resource="@xml/searchable"/>

The name of the activity is up to you; all the other tags and attributes must be as shown here.



Download 5.42 Mb.

Do'stlaringiz bilan baham:
1   ...   140   141   142   143   144   145   146   147   ...   223




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling