此问题通常是由于下拉菜单的数据源中包含空元素导致的。可以通过以下代码来解决:
String[] data = {"apple", "", "banana", "cherry", "", "durian"};
List
@Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); TextView textView = (TextView) view.findViewById(android.R.id.text1); if (TextUtils.isEmpty(textView.getText())) { view.setVisibility(View.GONE); view.setLayoutParams(new AbsListView.LayoutParams(0, 0)); } else { view.setVisibility(View.VISIBLE); view.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); } return view; }