내 listview에 약간의 문제가 있습니다. 모든 항목에는 몇 가지 정보와 확인란이 있습니다. 이것은 잘 나타나고 체크 박스를 선택하거나 해제 할 수 있습니다.많은 체크 박스가있는 ListView 어댑터
그러나 이상한 행동을 발견했습니다. 첫 번째 행에서 첫 번째 확인란을 클릭한다고 가정 해 보겠습니다. ListView가 작 으면 아래로 스크롤하지 않아도됩니다. 그러나 ListView가 크면 모든 항목을 보려면 아래로 스크롤해야하며 하단의 임의 항목도 클릭됩니다. 다른 방식으로 같은 동작이 발생합니다. 목록보기의 맨 아래에있는 확인란을 클릭하고 위로 스크롤하면 상단의 임의의 확인란도 클릭됩니다. 어딘가에 여러 개의 체크 박스를 클릭하면 같은 양의 클릭 된 체크 박스가있는 다른 장소가 있습니다. 나는 GetView (...)가 호출 될 때 이것이 일어난다는 것을 알아 냈다. 그런 다음 몇 가지 새로운 체크 박스를 클릭하게하지만 그 이유를 모르겠습니다.
여기에 약간의 도움을 감사하십시오! :) 내 어댑터의
SSSCE :
public class ListViewAdapterSSCCE : BaseAdapter
{
private Activity myActivity;
private string[] someData;
private int numberOfElements;
private CheckBox[] boxes;
public ListViewAdapterSSCCE(Activity activity)
{
this.myActivity = activity;
for (int i = 0; i < numberOfElements; i++)
this.boxes[i] = new CheckBox(myActivity);
}
public void SetData(string[] someData)
{
this.someData = someData;
this.numberOfElements = someData.Length;
}
public void CheckAllBoxes(bool isChecked)
{
for (int i = 0; i < numberOfElements; i++)
this.boxes[i].Checked = isChecked;
}
public override Java.Lang.Object GetItem(int position)
{
return null;
}
public override long GetItemId(int position)
{
return 10;
}
public override int Count
{
get { return numberOfElements; }
}
public override View GetView(int position, View convertView, ViewGroup parent)
{
if (convertView == null)
{
LayoutInflater inflater = (LayoutInflater)myActivity.GetSystemService(Context.LayoutInflaterService);
convertView = inflater.Inflate(Resource.Layout.ChildrenList_item, null);
}
var itemBox = convertView.FindViewById<CheckBox>(Resource.Id.checkbox);
this.boxes[position] = itemBox;
var textView = convertView.FindViewById<TextView>(Resource.Id.item_data);
textView.Text = this.someData[position];
return convertView;
}
}
두 번째로 나는 당신의 대답을 보았다. 나는 그 문제를 이해했다! 그것이 이런 식으로 될 것이라고 생각했습니다. 설명과 훌륭한 솔루션을 주셔서 감사합니다! –