我想在我的应用程序中实现searcb bar概念 . 当用户点击searbar时,键盘按钮需要在其中显示默认的可搜索按钮..i后面的链接很少...但无法获得可搜索的条形码或键盘填充按钮...
请提前帮助我 .
这是我的searchable.xml放置res / xml
<searchable
android:label="@string/app_label"
android:hint="@string/search_hint" >
</searchable>
这是我的清单文件
<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>
这是活动...包com.hands;
import android.app.Activity; import android.app.SearchManager; import android.content.Intent; import android.os.Bundle;
public class SearchboxActivity extends Activity {/ **首次创建活动时调用 . * / @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");
}
}