私はアクティビティツールバーで検索ウィジェットを持つことができることを理解しています。私の要求に応じて、検索ウィジェット用のツールバーを使用することはできません。ツールバーのすぐ下のアクティビティや、テキストビューやボタンのような検索ウィジェットを個別のエンティティとして使用できますか?アンドロイドのツールバー以外の検索ウィジェットを持つことができます
-3
A
答えて
1
私は、検索ビューのXMLを作成し、任意の場所私が欲しい含むことによって、それを使用しています。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:padding="16dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@android:color/white"
app:cardElevation="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.SearchView
android:id="@+id/searchView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:queryHint="Search..">
</android.support.v7.widget.SearchView>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
は、レイアウトに含める
<include layout="@layout/search_view" />
0
はいそれは可能です... ...このようにXMLで
を行いJavaでは
<FrameLayout
android:focusableInTouchMode="true"
android:id="@+id/searchBoxFrame"
android:layout_below="@+id/textViewTitle"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="16dp"
android:layout_width="fill_parent">
<EditText
android:background="@drawable/input_box"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 "
android:drawableLeft="@android:drawable/ic_menu_search"
android:hint="Search"
android:id="@+id/autoText"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:lines="1"
android:paddingLeft="7dp"
android:textSize="20sp" />
<Button
android:background="@android:drawable/ic_menu_close_clear_cancel"
android:id="@+id/searchBoxCancel"
android:layout_gravity="right|center_vertical"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_width="40dp"
android:visibility="gone" />
</FrameLayout>
private EditText searchEditText;
private Button cancelButton;
searchEditText = (EditText) findViewById(R.id.autoText);
cancelButton = (Button) findViewById(R.id.searchBoxCancel);
private void onEditTextItemChanged() {
searchEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
list.clear();
String editTextString = searchEditText.getText().toString();
int textLength = editTextString.length();
if (textLength > 0) {
cancelButton.setVisibility(View.VISIBLE);
} else {
cancelButton.setVisibility(View.GONE);
}
for (int i = 0; i < list.size(); i++) {
String searchText = "";
searchText = list.get(i).getName().toString();
if (textLength <= searchText.length()) {
// compare the String in EditText with Names in the
// ArrayList
if (searchText.toLowerCase().contains(editTextString.toLowerCase())) {
list.add(list.get(i));
}
}
}
listItemsAdapter = new listItemsAdapter(getApplicationContext(), list);
listView.setAdapter(listItemsAdapter);
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
private void onCancelButtonClicked() {
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
searchEditText.setText("");
}
});
}
関連する問題
- 1. ツールバーの検索ボタンを膨らませることができません
- 2. jqgridツールバーの検索または外部検索機能
- 3. ツールバーで検索
- 4. Searchviewは menu.xml私はツールバー内検索アイコンをクリックすると、アンドロイド
- 5. アンドロイドでカスタム検索を作成する(レイアウトに検索ウィジェットを挿入する)
- 6. jqgrid aotoツールバーでの検索
- 7. Amazon API - カテゴリALL - DVD以外を検索できますか?
- 8. 検索ウィジェットを使用してandroid:text = "______"フィールドのテキストを検索できますか?
- 9. オペレーションは2つ以上のオペランドを持つことができますか?
- 10. オブジェクトは、ゼロ以外のサイズ、1バイト以上の記憶域を持つことはできますか?
- 11. ここではVisual Studio 2013はツールバーの検索テキストボックスを見つける
- 12. アンドロイド検索で検索ウィジェット検索後に正しい位置が表示されない
- 13. Twitterの検索ウィジェット
- 14. 2つ以上のフィールドを持つSQL検索
- 15. ツールバーの検索のカスタマイズ
- 16. beforefieldinitは静的コンストラクタの実行時以外の効果を持つことができますか?
- 17. と条件付きの2つのフィールドを持つmongoosastic検索
- 18. Android - MapActivityの検索ツールバー
- 19. 検索ビューの提案が2ツールバー
- 20. Sitecore Multilist with sitecore以外の検索データソース
- 21. forEach以外の優れたソリューション検索
- 22. 配列を検索すると、1つの整数以外は整数
- 23. ツールバーの検索ボックスでコマンド入力を無効にすることはできますか?
- 24. どのようにカルーセルを持つアンドロイドでツールバーをコーディングするのですか?
- 25. サービス内のインテントを持つメソッドがFCにウィジェットを引き起こします
- 26. Javaコンパイラのエラーパズル:「内部クラスは静的宣言を持つことができません」 - 単純型以外
- 27. JQGridツールバー検索:列の複数の単語を検索
- 28. 検索バーのアンドロイドとPHPのバックエンドとしての検索クエリ
- 29. WP:オーバーライド検索ウィジェット
- 30. imagescは矩形以外のグリッドを持つフィーチャが好き[MATLAB]
お返事ありがとうございます。私もアンドロイドを使用して音声検索ボタンを追加しようとしています:voiceSearchMode = "showVoiceSearchButton"が表示されませんか?それについてのアイデア? –
私はそれのために行くでしょう。私はそれが完了したらあなたに通知します。 –