mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
search UI
This commit is contained in:
parent
1e3a3262a4
commit
834bc35318
|
@ -86,58 +86,52 @@ public class SearchTopFragment extends Fragment {
|
|||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
// Menuの設定
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ActionViewの取得
|
||||
|
||||
|
||||
// 虫眼鏡アイコンを最初表示するかの設定
|
||||
this.searchView.setIconifiedByDefault(true);
|
||||
|
||||
// Submitボタンを表示するかどうか
|
||||
|
||||
this.searchView.setSubmitButtonEnabled(false);
|
||||
|
||||
|
||||
if (!this.searchWord.equals("")) {
|
||||
// TextView.setTextみたいなもの
|
||||
|
||||
this.searchView.setQuery(this.searchWord, false);
|
||||
} else {
|
||||
String queryHint = self.getResources().getString(R.string.hello_blank_fragment);
|
||||
// placeholderみたいなもの
|
||||
|
||||
this.searchView.setQueryHint(queryHint);
|
||||
}
|
||||
this.searchView.setOnQueryTextListener(self.onQueryTextListener);
|
||||
}
|
||||
|
||||
private SearchView.OnQueryTextListener onQueryTextListener = new SearchView.OnQueryTextListener() {
|
||||
private final SearchView.OnQueryTextListener onQueryTextListener = new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String searchWord) {
|
||||
// SubmitボタンorEnterKeyを押されたら呼び出されるメソッド
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
|
||||
return self.setSearchWord(searchWord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
// 入力される度に呼び出される
|
||||
public boolean onQueryTextChange(String query) {
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
private boolean setSearchWord(String searchWord) {
|
||||
private boolean setSearchWord(String query) {
|
||||
|
||||
|
||||
if (searchWord != null && !searchWord.equals("")) {
|
||||
// searchWordがあることを確認
|
||||
|
||||
this.searchWord = searchWord;
|
||||
}
|
||||
// 虫眼鏡アイコンを隠す
|
||||
|
||||
this.searchView.setIconified(false);
|
||||
// SearchViewを隠す
|
||||
|
||||
this.searchView.onActionViewCollapsed();
|
||||
// Focusを外す
|
||||
|
||||
this.searchView.clearFocus();
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user