0
사용자 정의 팝업 창 내에 searchview가 있으며 아래 목록보기가 있습니다.Android, 사용자 정의 팝업의 searchview에 텍스트가 입력되지 않았습니다.
표준 searchview 시나리오를 구현하려고합니다. 검색 뷰에 텍스트를 입력하면 목록보기 내에 표시된 내용이 필터링됩니다.
어떤 이유인지, searchview 내에 텍스트를 입력 할 수 없습니다. 소프트 키보드는 잘 표시되지만 입력하면 텍스트가 입력되지 않습니다.
public void display(final LayoutInflater inflater, int layout, final View anchor, ArrayList<String> docs, String currentDoc){
LinearLayout popupView = (LinearLayout)inflater.inflate(layout, null);
final InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
if(mList == null){
mList = (ListView)popupView.findViewById(R.id.doc_pop_list);
}
mDocuments = docs;
adapter = new ArrayAdapter<String>(mContext, R.layout.list_item,docs);
mList.setAdapter(adapter);
searchDocs=(SearchView) popupView.findViewById(R.id.doc_list_search);
searchDocs.requestFocus();
searchDocs.setQuery("", false);
searchDocs.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String text) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean onQueryTextChange(String text) {
adapter.getFilter().filter(text);
return false;
}
});
mList.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
docName = mList.getItemAtPosition(position).toString();
mWindow.dismiss();
mListener.docSelected(docName.toString());
}
});
Button dismiss = (Button)popupView.findViewById(R.id.button_docs_close);
dismiss.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
mWindow.dismiss();
}
});
위의 자바 코드를 참조하십시오. 내 XML로
나는 사용자 지정 목록보기 항목이 있습니다
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:textColor="#000000" />
을 그리고 이것은이 레이아웃에 표시됩니다 :이 문제의 원인이 무엇인지에
<SearchView
android:id="@+id/doc_list_search"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:queryHint="Search documents..." >
</SearchView>
</RelativeLayout>
<ListView
android:id="@+id/doc_pop_list"
android:layout_width="match_parent"
android:layout_height="420dp"
android:layout_above="@+id/doclist_close"
android:layout_below="@+id/docs_title"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="#ffffff" >
</ListView>
<Button
android:id="@+id/button_docs_close"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/blue"
android:text="@string/close"
android:textColor="@color/white" />
.....
어떤 아이디어? 당신이 뭔가를 입력 할 때
감사
좋아. 텍스트가 바뀌고있을 때 캡처 할 수있는 몇 가지 중단 점을 추가했습니다. – mangledBadger
Ok 코드를 테스트 한 결과 (기본 기능 만) 입력이 잘되어 있습니다. 아마도 도움이 될 것입니다 (편집 된 답변보기). – SILL
안녕하세요, 고맙습니다. 위의 내용을 시도했지만, 사용 방법에 맞게 리팩터링했지만 필수 사항은 그대로 유지했습니다. 아직도 아무 일도 일어나지 않는다. 자, 내 커스텀 팝업 뷰가 소프트 키보드 위에 표시됩니다. CSS z-index는 이것이 적절하다고 생각합니까? 독립 실행 형 작업에서 위와 동일한 구현을 사용하고 있으며 정상적으로 작동합니다. 그것은이 사용자 정의보기 내에서 구현 될 때 작동하지 않습니다. – mangledBadger