내 application.now에서 검색보기를 사용하고 있습니다. searchview 텍스트 상자에 입력 된 텍스트를 가져 와서 다른 textview.if에 표시하고 싶습니다. 텍스트를 입력하고 버튼을 내가 same.but 내가 할 수있는 여분의 buttons.i을 사용하고 싶습니다 그냥 결과 key.plz 사람이 나를 도울 때 표시하고 싶습니다 .. (만약 어떤 사람이 내게 코드를 제공하는 청취자 PLZ suggeting)android에서 searchview의 이벤트를 얻는 방법
답변
는 SearchView
new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String newText) {
// your text view here
textView.setText(newText);
return true;
}
@Override
public boolean onQueryTextSubmit(String query) {
textView.setText(query);
return true;
}
}
:
이 RXAndroid를 얻을 수 REPO를 이눔 수있는 링크입니다 .... –
잘 작동합니다. 먼저 searchview에 리스너를 추가해야했습니다. – Asim
입력 된 문자열이 비어 있지 않으면 리스너가 아니거나 onQueryTextSubmit이 작동하지 않습니다. –
위의 대답은 좋은 그러나 당신이 당신의 검색보기 위해 액션 청취자를 설정할 필요가 실제로 완료하지의 setOnQueryTextListener를 사용해보십시오.
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
callSearch(query);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
// if (searchView.isExpanded() && TextUtils.isEmpty(newText)) {
callSearch(newText);
// }
return true;
}
public void callSearch(String query) {
//Do searching
}
});
: 당신은 OnQueryTextListener을하고 그 새로운 객체를 만들어 다음과 같은 컴팩트 한 당신의 검색보기 쿼리 텍스트 리스너로 사용하거나 사용하는 데 필요한 클래스를 구현하는 클래스를 만드는 두 가지 방법으로이 작업을 수행 할 수 있습니다 또한이 같은 제이크 와튼에 의해 RXAndroid 및 RxBinding 수행 할 수 있습니다 :
RxSearchView.queryTextChanges(searchView)
.debounce(500, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<CharSequence>() {
@Override
public void call(CharSequence charSequence) {
if(charSequence!=null){
// Here you can get the text
System.out.println("SEARCH===" + charSequence.toString());
}
}
});
코드는 500 밀리 초 일부 지연 텍스트의 변화를 관찰하기 위해 가입한다. 작업이 아니다 나는 그것을 이러지 시도 내가 많은 청취자를했지만, 그들 중 누구도 working.i DNT KNW D 이유를 r에하지 https://github.com/JakeWharton/RxBinding
- 1. android에서 DialogResult를 얻는 방법?
- 2. android에서 windowonfocuschange() 이벤트를 설정하는 방법
- 3. Android에서 터치 이벤트를 감지하는 방법
- 4. android에서 Button의 너비를 얻는 방법
- 5. Android에서 언어 목록을 얻는 방법
- 6. android에서 로그 정보를 얻는 방법
- 7. android에서 현재 위치를 얻는 방법
- 8. android에서 프로세서 번호를 얻는 방법
- 9. CPTLayer에서 터치 이벤트를 얻는 방법?
- 10. 저장 파일에 이벤트를 얻는 방법
- 11. IE에서 onunload 이벤트를 얻는 방법
- 12. CALayer에서 터치 이벤트를 얻는 방법?
- 13. WebView에서 터치 이벤트를 얻는 방법
- 14. 지속적인 터치 이벤트를 얻는 방법?
- 15. android에서 HTML 이미지 클릭 이벤트를 처리하는 방법
- 16. 특정 이벤트를 클릭하면 Android에서 캘린더 일정 정보를 얻는 방법은 무엇입니까?
- 17. android에서 맞춤식 가상 키보드를 얻는 방법?
- 18. 발견 후 android에서 블루투스 RSSI를 얻는 방법
- 19. android에서 Webview의 너비와 높이를 얻는 방법
- 20. android에서 앱 설치 시간을 얻는 방법
- 21. android에서 위성에 대한 정보를 얻는 방법?
- 22. Android에서 연락처의 사진을 얻는 방법 (가장 효율적)
- 23. 캔버스에있는 버튼 클릭의 이벤트를 얻는 방법 - 안드로이드?
- 24. gridview의 버튼에서 클릭 이벤트를 얻는 방법
- 25. TreeView ContextMenu에서 MenuItem 클릭 이벤트를 얻는 방법
- 26. Android Softkeboard에서 키 코드 이벤트를 얻는 방법
- 27. blur 이벤트 다음에 포커스 이벤트를 얻는 방법?
- 28. 다른 제어 이벤트에서 이벤트를 얻는 방법?
- 29. 안드로이드에서 부재중 전화 이벤트를 얻는 방법?
- 30. 편집 가능한 ComboBox에서 TextChanged 이벤트를 얻는 방법
... –