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
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
// Menuの設定
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ActionViewの取得
|
|
||||||
|
|
||||||
|
|
||||||
// 虫眼鏡アイコンを最初表示するかの設定
|
|
||||||
this.searchView.setIconifiedByDefault(true);
|
this.searchView.setIconifiedByDefault(true);
|
||||||
|
|
||||||
// Submitボタンを表示するかどうか
|
|
||||||
this.searchView.setSubmitButtonEnabled(false);
|
this.searchView.setSubmitButtonEnabled(false);
|
||||||
|
|
||||||
|
|
||||||
if (!this.searchWord.equals("")) {
|
if (!this.searchWord.equals("")) {
|
||||||
// TextView.setTextみたいなもの
|
|
||||||
this.searchView.setQuery(this.searchWord, false);
|
this.searchView.setQuery(this.searchWord, false);
|
||||||
} else {
|
} else {
|
||||||
String queryHint = self.getResources().getString(R.string.hello_blank_fragment);
|
String queryHint = self.getResources().getString(R.string.hello_blank_fragment);
|
||||||
// placeholderみたいなもの
|
|
||||||
this.searchView.setQueryHint(queryHint);
|
this.searchView.setQueryHint(queryHint);
|
||||||
}
|
}
|
||||||
this.searchView.setOnQueryTextListener(self.onQueryTextListener);
|
this.searchView.setOnQueryTextListener(self.onQueryTextListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SearchView.OnQueryTextListener onQueryTextListener = new SearchView.OnQueryTextListener() {
|
private final SearchView.OnQueryTextListener onQueryTextListener = new SearchView.OnQueryTextListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextSubmit(String searchWord) {
|
public boolean onQueryTextSubmit(String query) {
|
||||||
// SubmitボタンorEnterKeyを押されたら呼び出されるメソッド
|
|
||||||
return self.setSearchWord(searchWord);
|
return self.setSearchWord(searchWord);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextChange(String newText) {
|
public boolean onQueryTextChange(String query) {
|
||||||
// 入力される度に呼び出される
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private boolean setSearchWord(String searchWord) {
|
private boolean setSearchWord(String query) {
|
||||||
|
|
||||||
|
|
||||||
if (searchWord != null && !searchWord.equals("")) {
|
if (searchWord != null && !searchWord.equals("")) {
|
||||||
// searchWordがあることを確認
|
|
||||||
this.searchWord = searchWord;
|
this.searchWord = searchWord;
|
||||||
}
|
}
|
||||||
// 虫眼鏡アイコンを隠す
|
|
||||||
this.searchView.setIconified(false);
|
this.searchView.setIconified(false);
|
||||||
// SearchViewを隠す
|
|
||||||
this.searchView.onActionViewCollapsed();
|
this.searchView.onActionViewCollapsed();
|
||||||
// Focusを外す
|
|
||||||
this.searchView.clearFocus();
|
this.searchView.clearFocus();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user