0
是否可以将搜索对话框固定在应用程序活动的顶部?Android搜索对话框始终可见
问题是我的是,如果用户点击活动中的其他位置,错误地说,搜索对话框关闭,用户必须点击搜索电话按钮。
由于我的示例应用程序是一个搜索应用程序,我希望它始终在我的活动顶部可见。
有没有办法,android API允许这样吗?
感谢
编辑与代码:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
onSearchRequested();
Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
Log.d("search", query);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
活动:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world" />
</RelativeLayout>
searchconfig
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_name" >
</searchable>
谢谢斯蒂芬,我已经添加了我的示例POC中的代码。 – Cavish
Infact,我希望它在应用程序开始以及结果活动(列表活动)的情况下可见。但是软键只有在对话框处于活动状态时才会出现,(点击)您可以让我知道如何做到这一点? – Cavish
或者..是否有可能把这个Android默认搜索对话框放在一个单独的布局中并且始终显示,而不管在活动中被点击什么? 如果可以,请让我知道如何做到这一点,使用上述布局我有什么? 谢谢 – Cavish