그래서 저는 textViews 격자를 가지며 228 개의 셀로 구성됩니다. 사용자가 그리드의 셀을 클릭하면 셀의 색이 바뀝니다. 그러나 위 또는 아래로 스크롤하면 다른 셀로 색이 이동합니다. 사용자 정의 그리드 뷰 어댑터를 사용했습니다. 다음은 getView()의 코드입니다.안드로이드 그리드보기에서 셀의 색이 스크롤 할 때 변경됩니다.
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View gridView;
if(convertView == null) {
convertView = inflater.inflate(R.layout.fingerprintlayout, null);
}
TextView tv = (TextView)convertView.findViewById(R.id.textView);
tv.setText(gridV[position]); //Setting the text
if(position == getClickedCellPosition()){
convertView.setBackgroundColor(Color.BLUE); //Setting the background color
}
return convertView;
}