사용자가 listView 안에있는 체크 박스를 클릭하면 텍스트에 strikethough를 설정하고 싶습니다 .ListView 안에 세 개의 항목이 있다고 가정하지만 첫 번째 항목에서 체크 상자를 클릭하면 텍스트에만 적용됩니다 마지막 항목의.Strikethough text listView 안드로이드에 텍스트 설정
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
listView = (ListView) findViewById(R.id.productList);
model = helper.getAllProduct(list);
startManagingCursor(model);
listView.setAdapter(new ShoppingListAdapter(this,model));
class ShoppingListAdapter extends ResourceCursorAdapter {
public ShoppingListAdapter(Context context ,Cursor c) {
super(context,R.layout.productrow,c);
// TODO Auto-generated constructor stub
}
@Override
public void bindView(View row, Context context, Cursor c) {
// TODO Auto-generated method stub
listName = (TextView) row.findViewById(R.id.produtName);
final CheckBox listCheck=(CheckBox)row.findViewById(R.id.check);
listCheck.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton view, boolean isChecked) {
// TODO Auto-generated method stub
if(listCheck.isChecked()){
listName.setPaintFlags(listName.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
//listName.setTextColor(_context.getResources().getColor(R.color.red));
// listName.setText("go");
}
}
});
아무도 내 실수가 아닐까요?
이미 검사 된 플래그에 대해서도 onCheckedChange 외부에 플래그를 설정하십시오. – Doomsknight
외부에 플래그를 설정 하시겠습니까? 나도 밖에서 setPaintFlag 뜻? 죄송합니다, 안드로이드 프로그래밍에 새로운입니다. – johnk