좋아, 나는 한 다음과 같은 요구 사항 : 일부 안드로이드 버전에서 PopupWindow 내부의 ListView는 팝업에 초점을 맞출 수 없을 때 터치 이벤트를받지 못합니까?
- 글고 제안 팝업 @ 사용자 유형
- 사용자를 나타나면있는이 제안을 필터링합니다 계속 입력 할 수 있습니다 그것을 여기
PopupWindow popupWindow = new PopupWindow(mContext);
// Create ListView to show the suggestions
ListView listView = new ListView(mContext);
listView.setBackgroundColor(Color.WHITE);
MentionsAdapter adapter = new MentionsAdapter(mContext, suggestions);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String username = mSuggestions.get(position);
String mentionCompletion = username.substring(mCurrentQuery.length()).concat(" ");
mEditor.getText().insert(mEditor.getSelectionEnd(), mentionCompletion);
hideSuggestions();
}
});
mSuggestionsListView = listView;
popupWindow.setContentView(listView);
popupWindow.setFocusable(false);
popupWindow.setTouchable(true);
popupWindow.setOutsideTouchable(true);
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
clearPopupData();
}
});
Rect popupRect = calculatePopupPosition();
popupWindow.setWidth(popupRect.width());
popupWindow.setHeight(popupRect.height());
popupWindow.showAtLocation(mEditor, Gravity.START | Gravity.TOP, popupRect.left, popupRect.top);
mPopupWindow = popupWindow;
작동하지 않습니다! 문제는 일부 Android 버전/기기에서만 작동한다는 것입니다. 예를 들어 에뮬레이터의 Android 6.0에서 작동하지만 동료 6.0의 LG G4에서는 작동하지 않습니다. Android 4.3.1에서는 작동하지 않지만 4.4.2에서는 작동합니다. PopupWindow
에 포커스를 설정할 수없는 경우 ListView
의 OnItemClickListener
이 호출되지 않습니다. PopupWindow
에 포커스가있는 경우 ListView
의 OnItemClickListener
은 호출되지만 EditText
은 키보드 이벤트를 수신하지 않습니다. PopupWindow
및 ListView
에서 초점/터치 모드를 변경하는 수많은 조합을 시도했지만 이러한 경우에는 작동하지 않습니다.
WFT에 대한 제안 사항이 있으며 해결 방법은 무엇입니까?