问题描述
这是我的下面的代码
public class EntityAdapter extends ArrayAdapter<EntityDropDown> {
public EntityAdapter(Context context,ArrayList<EntityDropDown> locations) {
super(context,locations);
}
public View getView(int position,@Nullable View convertView,@NonNull ViewGroup parent)
{
return initView(position,convertView,parent);
}
public View getDropDownView(int position,@NonNull ViewGroup
parent) {
return initView(position,parent);
}
@Override
public boolean isEnabled(int position){
EntityDropDown entity = getItem(position);
if (entity.getEntityName().length() == 1) {
return false;
}
else {
return true;
}
}
private View initView(int position,View convertView,ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(
R.layout.drop_down_rows,parent,false
);
}
TextView textView = convertView.findViewById(R.id.row_text_view_1);
EntityDropDown entity = getItem(position);
if (entity != null) {
if (entity.getEntityName().length() == 1) {
textView.setText(entity.getEntityName());
textView.setTypeface(Typeface.DEFAULT_BOLD);
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP,20);
} else {
textView.setText(entity.getEntityName());
}
}
return convertView;
}
}
我的实体列表为
("a","AA","abcd","b","bbb","bcde",....
"z","zzz","zabc")
我执行
var adapter = EntityAdapter()
adapter = EntityAdapter(
requireContext(),entityList
)
listView.adapter = adapter
其中EntityList为上面的
我要突出显示粗体的字母,它们的长度为1,而不是长度为1,它们是正常/常规的。
问题是当我上下滚动时,列表下拉列表的内容会随机更改,大于1的长度是粗体,我尝试调试但没有找到解决方法。
我们将不胜感激,谢谢您。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)