我正在使用 CheckedTextView 处理列表视图,
下面是我的代码:
RelativeLayout parentMostLayout = new RelativeLayout(activity);
parentMostLayout.setLayoutParams(new AbsListView.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.WRAP_CONTENT));
CheckedTextView checkedTextView = new CheckedTextView(activity);
int[] attrs = { android.R.attr.listChoiceIndicatorMultiple };
TypedArray ta = activity.getTheme().obtainStyledAttributes(attrs);
Drawable indicator = ta.getDrawable(0);
checkedTextView.setCheckMarkDrawable(indicator);
ta.recycle();
parentMostLayout.addView(checkedTextView, checkedTextViewlLayoutParams);
当我尝试检查该项目时,它没有标记我要选择的项目,这可能是什么问题?
编辑
ListView listView = new ListView(activity);
listView.setCacheColorHint(Color.TRANSPARENT);
listView.setDivider(new ColorDrawable(0x99000000));
listView.setDividerHeight(1);
listView.setSelector(R.drawable.listselector);
RelativeLayout.LayoutParams listViewParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT);
listViewParams.addRule(RelativeLayout.ABOVE, footerBar.getId());