2013-08-20 2 views
1

내 응용 프로그램에서 textview 및 customview viewview 값이 bindview.My 문제에서 호출 할 수 있습니다.보기에 5 목록을 추가하는 경우입니다. 취소 선 텍스트는 마지막 체크 상자에서만 작동합니다. 왜이 문제가 bindview에서 발생하는지 알 수 있습니다. 미리 감사드립니다. u는 당신의 목록보기에 항목을 추가하는 경우체크 상자 상태에서 취소 선 텍스트보기 Android?

public class CustomContacts extends SimpleCursorAdapter{ 
private LayoutInflater mLayoutInflater; 
// private Context context; 
private int col=0; 
private int col1=0; 
public static boolean itemreminder; 
int id; 
private TextView tcontent; 
int id1; 
private CheckBox check; 
public static int checkbox = 0; 
SwipeDetector swipedetector; 
@SuppressWarnings("deprecation") 
public CustomContacts(Context context, int layout, Cursor c, String[] from, 
     int[] to) { 
    super(context, layout, c, from, to); 
    // TODO Auto-generated constructor stub 
    mLayoutInflater = LayoutInflater.from(context); 

} 
@Override 
public View newView(Context context, Cursor cursor, ViewGroup parent) { 
    return mLayoutInflater.inflate(R.layout.activity_contactitem, null); 
} 
@Override 
public void bindView(View view, final Context context, final Cursor c) { 
    final int id = c.getInt(c.getColumnIndex(Contactsnew.userid)); 
    Log.d("id", Integer.toString(id)); 
    final int id1 = c.getInt(c.getColumnIndex(Contactsnew.userId1)); 
    Log.d("id1", Integer.toString(id1)); 
    final int id2 = c.getInt(c.getColumnIndex(Contactsnew.listId)); 
    Log.d("id2", Integer.toString(id2)); 
    final String content = c.getString(c.getColumnIndex(Contactsnew.CONTENT)); 
    Log.d("co", content); 
    final int checkbox = c.getInt(c.getColumnIndex(Contactsnew.ITEMREMINDER)); 
    Log.d("checkn", Integer.toString(checkbox)); 
    String valcheck = Integer.toString(checkbox); 
    tcontent = (TextView)view.findViewById(R.id.content123); 
     tcontent.setText(content); 

    check = (CheckBox)view.findViewById(R.id.itemcheck); 
    if(checkbox == 1){ 
     ImageView iv = (ImageView) view.findViewById(R.id.photo1234); 
     iv.setImageResource(R.drawable.cancel); 
     check.setChecked(true); 
     tcontent.setPaintFlags(tcontent.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); 

    }else if(checkbox == 0){ 
     ImageView iv = (ImageView) view.findViewById(R.id.photo1234); 
     iv.setImageResource(R.drawable.remind); 
     check.setChecked(false); 
     tcontent.setPaintFlags(tcontent.getPaintFlags() & ~ Paint.STRIKE_THRU_TEXT_FLAG); 

    } 
     TextView text1 = (TextView)view.findViewById(R.id.editviewcon); 
     RelativeLayout layout = (RelativeLayout)view.findViewById(R.id.linear123); 
     if (col % 2 != 1) { 
      layout.setBackgroundColor(0xFFC1E7FF); 
     } else { 
      layout.setBackgroundColor(0xFF98D4FA); 
     } 
     col++; 
     LinearLayout layou1 = (LinearLayout) view.findViewById(R.id.linearali11); 
     if (col1 % 2 != 1) { 
      layou1.setBackgroundColor(0xFF87CEFA); 
     } else { 
      layou1.setBackgroundColor(0xFF6495ED); 
     } 
     col1++; 
     final TextView ttext = (TextView)view.findViewById(R.id.finaltext); 
     final LinearLayout ll = (LinearLayout) view.findViewById(R.id.ll11); 


     final SQLiteConnectornew sqlCon = new SQLiteConnectornew(context); 
     check.setOnCheckedChangeListener(new OnCheckedChangeListener() 
     { 
      public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) 
      { 
       if (check.isChecked()) 
       { 
        // perform logic 
        itemreminder = true; 
        sqlCon.updatable1(itemreminder, id, id1); 
        tcontent.setPaintFlags(tcontent.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); 
       } 
       else { 
        itemreminder = false; 
        sqlCon.updatable1(itemreminder, id, id1); 
        tcontent.setPaintFlags(tcontent.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG); 
       } 
      } 
     }); 

     view.setOnClickListener(new OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       // TODO Auto-generated method stub 
       if (!Alertadditem.clicked) { 
        //_id1 = GetSet.getUserId(); 
        Intent intent = new Intent(context, Alertedit.class) 
          .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
        intent.putExtra("id", id); 
        intent.putExtra("id1", id1); 
        intent.putExtra("id2", id2); 
        Log.d("id", "reacged2"); 
        intent.putExtra("content", content); 
        context.startActivity(intent); 
       } 

답변

1

당신은 당신이 삽입 된 마지막 항목의보기를 할게요의 Bindview 방법의 모든 5 개 많은 ListItems의 strikethroughtext, 사촌을 사용할 수 없습니다. 그래서 마지막 항목에 대해서만 텍스트를 칠 수 있습니다! 극복하는 가장 좋은 방법은 mainclass에서 custadapter를 사용하고 listview를 찾고 onclicklistener를 설정하고 해당보기 아래에 취소 선을 사용 해보십시오 !!

관련 문제