我在片段中有自定义列表视图,在项目点击文本颜色更改和选框运行时,但在第一次项目单击时没有任何东西工作,没有选框或没有文本颜色更改,并在第二次单击两个工作精细。请帮助!!
for (const auto &it : directory_range(folder)) {
if(expression){
std::cout << "\n :clean: removing file : " << it.path();
bfs::remove(it.path());
}
}
布局:
mainListViews.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
textView = (TextView) view.findViewById(R.id.textView);
String text = textView.getText().toString();
song_namef.setText(text);
setItemNormal();
View rowView = view;
views=rowView;
setItemSelected(rowView);
}});
public void setItemSelected(View view){
View rowView = view;
TextView tv = (TextView)rowView.findViewById(R.id.textView);
tv.setTextColor(Color.WHITE);
tv.setEllipsize(TextUtils.TruncateAt.MARQUEE);
tv.setSingleLine(true);
tv.setHorizontallyScrolling(true);
tv.setSelected(true);
tv.requestFocus();
}
public void setItemNormal()
{
for (int i=0; i< mainListViews.getChildCount(); i++)
{
View v = mainListViews.getChildAt(i);
TextView txtview = ((TextView)v.findViewById(R.id.textView));
txtview.setSelected(false);
txtview.setSingleLine(true);
txtview.setTextColor(getResources().getColor(R.color.tabsScrollColor));
}}
答案 0 :(得分:0)
将 android:descendantFocusability =&#34; blocksDescendants&#34; 添加到您的订单项 它应该工作正常 如果您仍然遇到问题,请告诉我