I am hiding keyboard on click on the edit text which is an anchor view to list popup window but the list is shown at a wrong place not on the required anchor view. But it works perfectly fine if the keyboard is already hidden i.e. the list is shown at the right position.
onCLick()
Utility.keyboardDown(getActivity());
if (Build.VERSION.SDK_INT >= 23) {
country.setHintTextColor(ContextCompat.getColor(context, R.color.create_new_account_forgot_password_colorcode));
} else {
country.setHintTextColor(getResources().getColor(R.color.create_new_account_forgot_password_colorcode));
}
listPopupWindowCountry = new ListPopupWindow(getContext());
countryPopupListAdapter = new CountryPopupListAdapter(getContext(), R.layout.support_simple_spinner_dropdown_item, countryList);
setCountryPopUpWindow();
listPopupWindowCountry.show();
country.setHintTextColor(getResources().getColor(R.color.create_new_account_forgot_password_colorcode));
break;
METHOD setCountryPopUpWindow()
private void setCountryPopUpWindow() {
listPopupWindowCountry.setAdapter(countryPopupListAdapter);
listPopupWindowCountry.setAnchorView(country);
listPopupWindowCountry.setModal(true);
listPopupWindowCountry.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
CountryModel countryModel = countryList.get(position);
if ((Utility.getText(state) != null || Utility.getText(city) != null)
&& !(Utility.getText(country).equals(countryModel.getName()))) {
state.setText("");
city.setText("");
}
country.setText(countryModel.getName());
countryWrapper.setError(null);
stateWrapper.setError(null);
stateWrapper.setErrorEnabled(false);
if (stateList != null) {
stateList.clear();
}
AppPreferences.getInstance(getContext()).setPhoneCode(countryModel.getPhonecode() + "");
countryID = countryModel.getId();
stateList = new CountryStateCityFileHandler().getStates(countryModel);
listPopupWindowCountry.dismiss();
}
});
listPopupWindowCountry.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
listPopupWindowCountry.dismiss();
}
});
}