public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder vh;
final int pos = position;
int point, cash, temp3, totalCost;
boolean[] tld_val = new boolean[7];
double temp;
String temp2;
Intent intent = ((Activity) mContext).getIntent();
tld = intent.getExtras().getString("Value");
if (convertView == null) {
LayoutInflater Inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = Inflater.inflate(R.layout.point_item_layout, parent,
false);
vh = new ViewHolder();
vh.mTextView = (TextView) convertView
.findViewById(R.id.coupon_text);
vh.mCheckBox = (CheckBox) convertView
.findViewById(R.id.coupon_checkbtn);
vh.mCheckBox.setId(position);
convertView.setTag(vh);
} else {
vh = (ViewHolder) convertView.getTag();
}
if (!mDataArr.get(pos).mName.contains(".")) {
vh.mCheckBox.setEnabled(true);
vh.mTextView.setTextColor(Color.RED);
}
if (tld.contains("com")){
if(mDataArr.get(pos).mName.contains("com")){
vh.mCheckBox.setEnabled(true);
vh.mTextView.setTextColor(Color.RED);
}
}
if (tld.contains("net")){
if(mDataArr.get(pos).mName.contains("net")){
vh.mCheckBox.setEnabled(true);
vh.mTextView.setTextColor(Color.RED);
}
}
if (tld.contains("co.kr")){
if(mDataArr.get(pos).mName.contains("co.kr")){
vh.mCheckBox.setEnabled(true);
vh.mTextView.setTextColor(Color.RED);
}
}
if( tld.contains("kr")){
if(mDataArr.get(pos).mName.contains("kr")){
vh.mCheckBox.setEnabled(true);
vh.mTextView.setTextColor(Color.RED);
}
}
if (tld.contains("org")){
if(mDataArr.get(pos).mName.contains("org")){
vh.mCheckBox.setEnabled(true);
vh.mTextView.setTextColor(Color.RED);
}
}
if(tld.contains("info")){
if(mDataArr.get(pos).mName.contains("info")){
vh.mCheckBox.setEnabled(true);
vh.mTextView.setTextColor(Color.RED);
}
}
if(tld.contains("me")){
if(mDataArr.get(pos).mName.contains("me")){
vh.mCheckBox.setEnabled(true);
vh.mTextView.setTextColor(Color.RED);
}
}
vh.mTextView.setText(mDataArr.get(pos).mName);
vh.mCheckBox.setChecked(mDataArr.get(pos).mChecked);
vh.mCheckBox.setTag(mDataArr.get(pos));
vh.mCheckBox.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
if (vh.mCheckBox.isChecked()) {
coupon_chk_cnt += 1;
} else {
coupon_chk_cnt -= 1;
}
});
return convertView;
}
보시면 알겠지만 리스트뷰에 getView() 쪽 소스입니다.
들어오는 tld 값은
com ,co.kr, me 이런값들이 여러게 들어옵니다.
switch 문을 쓰려고 해보니까 문자열이나 배열로 비교해야하는데 그렇게는 switch 문을 못쓰더라고여
위 소스처럼 if 문을 썻을때는 리스트에 잘 적용되서 나오는데 스크롤을 내렸다가 올리면
vh.mTextView.setTextColor(Color.RED) 이게 아무대나 적용되는 문제가 생기고여 그걸 막자고
if(tld.contains("info")){
vh.mCheckBox.setEnabled(true);
vh.mTextView.setTextColor(Color.RED);
} else{
vh.mCheckBox.setEnabled(false);
vh.mTextView.setTextColor(Color.GRAY);
}
이런식으로 처리하면 리스트 전부를 바꿔버려서 문젭니다..
아니면 다른 방법으로 스크롤을 내렷다 올릴시 값이 안바뀌도록 설정하는 방법에 대해 도와주셔도 감사하겟습니다.
제가 필력이 딸리는것도 있고 직접보여주지 않는이상 설명하기 많이 까다로운 부분이라 양해좀 부탁드리면서 혹시
좋은 방법있으시면 도와주시기 바랍니다 .ㅠ