问题
i want to implement searcb bar concept in my app . when ever user clicks on searbar the keyboard buttons need to display with default searchable button in it ..i followed few of the links ...but unable to get the searchable bar nor the keyboard populated buttons ...
please help me thanks in advance .
this is my searchable.xml placed res/xml
<searchable
android:label="@string/app_label"
android:hint="@string/search_hint" >
</searchable>
and this is my manifest file
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".SearchboxActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable"/>
</activity>
</application>
here is the activity ... package com.hands;
import android.app.Activity; import android.app.SearchManager; import android.content.Intent; import android.os.Bundle;
public class SearchboxActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
// Get the intent, verify the action and get the query
Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
// doMySearch(query);
}
}
private void doMySearch(String query) {
// TODO Auto-generated method stub
System.out.println("hello 2");
}
}
来源:https://stackoverflow.com/questions/16515964/i-want-to-implement-searchbar-concept-in-my-app