HAFR: Update Search TextView

* Allow pressing search on keyboard to start the search
* Only allow single line in textview

Change-Id: I8dd91c4a84f03c228174b80494251254185f96e1
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
Christian Oder
2018-02-20 19:58:35 +01:00
committed by Hưng Phan
parent aa5c65a006
commit a27568245c
2 changed files with 22 additions and 1 deletions

View File

@@ -14,6 +14,9 @@
android:layout_height="fill_parent"
android:layout_toLeftOf="@+id/searchButton"
android:ems="10"
android:imeOptions="actionSearch"
android:maxLines="1"
android:inputType="text"
android:hint="@android:string/search_go" >
</EditText>

View File

@@ -2,15 +2,18 @@ package com.cherish.settings.fragments;
import android.app.Dialog;
import android.content.Context;
import android.view.inputmethod.EditorInfo;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.EditText;
import android.widget.Filter;
import android.widget.ImageButton;
import android.view.KeyEvent;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.TextView;
import com.android.settings.R;
@@ -68,6 +71,21 @@ public abstract class HAFRAppChooserDialog extends Dialog {
}
});
dSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
dAdapter.getFilter().filter(dSearch.getText().toString(), new Filter.FilterListener() {
public void onFilterComplete(int count) {
dAdapter.update();
}
});
return true;
}
return false;
}
});
dAdapter.update();
}