android - Android Multiline autocompletetextview 下拉滚动出现一项错误
问题描述
我为我的 Autocompletetextview android 创建了多行下拉项。在下拉滚动中,只有一两个项目检查附加的屏幕截图。当项目超过 5 项时,应出现下拉菜单中的滚动。对于单个多行项目,因为在滚动被剪切时可以看到滚动完整项目信息。
我的项目 XML
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/underline">
<com.rm.partner.customview.CustomTextView
android:id="@+id/autoCompleteSpinnerText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="left|center"
android:maxLines="10"
android:padding="@dimen/margin_5dp"
android:scrollHorizontally="false"
android:textColor="@color/grey_textcolor"
app:fontName_TextView="@string/FONT_PROXIMANOVALIGHT"/>
</LinearLayout>
自动完成文本视图
<AutoCompleteTextView
android:id="@+id/select_scheme_spinner"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.90"
android:background="@android:color/transparent"
android:hint="@string/autocomplete_hint"
android:imeOptions="actionDone"
android:inputType="none"
android:overlapAnchor="false"
android:paddingLeft="@dimen/margin_5dp"
android:paddingRight="@dimen/margin_5dp"
android:textColor="@color/grey_textcolor"
android:textColorHint="@color/grey_textcolor"
android:textCursorDrawable="@drawable/custom_cursor_grey"
android:textSize="@dimen/font_12sp"
android:theme="@style/Widget.AppCompat.AutoCompleteTextView"
app:fontName_TextView="@string/FONT_PROXIMANOVALIGHT" />
自定义适配器 getView
@Override
public View getView(int position, View convertView, ViewGroup parent) {
try {
final ViewHolder viewHolder; // view lookup cache stored in tag
final ClientFolioResponse.ResponseListObjectBean schemeOptionObj = dataSet.get(position);
final View result;
if (convertView == null) {
viewHolder = new ViewHolder();
LayoutInflater inflater = LayoutInflater.from(getContext());
convertView = inflater.inflate(R.layout.spiner_item_reft, parent, false);
viewHolder.schemeName = convertView.findViewById(R.id.autoCompleteSpinnerText);
result = convertView;
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
result = convertView;
}
if (schemeOptionObj.getFolioNo().length()>0) {
String schemeNameText = schemeOptionObj.getFolioNo() + "/" + schemeOptionObj.getSchemeName();
viewHolder.schemeName.setText(schemeNameText);
} else {
viewHolder.schemeName.setText(schemeOptionObj.getSchemeName());
}
result.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
InputMethodManager imm = (InputMethodManager) getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(
view.getApplicationWindowToken(), 0);
}
}
return false;
}
});
} catch (Exception e) {
e.printStackTrace();
}
return convertView;
}
解决方案
推荐阅读
- python - 如何检测乌龟是否在 x & y 的半径内然后做点什么?
- spring-boot - Zuul 代理和 ssl
- python - 如何在 Keras 中使用 tensorflow.python.ops?
- c# - 执行 MSBuild 的 SonarScanner 失败?
- excel - 查找给定范围内空单元格的行索引
- azure - 如何验证\检查 Azure VM 的强化?
- c# - 为什么同时具有 _ViewStart 和 _ViewImports?为什么不是一个文件?
- typescript - 基于视口的条件属性
- python - matplotlib:我可以使用辅助字体来丢失字形吗?
- android - 使服务无限期运行并与活动通信