안드로이드 개발 질문/답변
(글 수 45,052)
누가 좀 도와주세요~~ ㅠㅠ
아래 이미지 처럼, 우측 버튼을 클릭하면 좌측 EditText의 백그라운드 이미지가 바뀌어야하는데,
1행을 처음 클릭하면 8행의 이미지가 바뀌고, 다시 클릭하면 그 때서야 1행의 이미지가 바뀝니다..
그리고,
1행을 클릭하면 8행의 이미지가 바뀌고,
2행을 클릭하면 7행의 이미지가 바뀌고
3행을 클릭하면 6행의 이미지가 바뀌네요...ㅠㅠ
도대체 뭐가 문제일까요...
Log를 찍어보면 position의 위치는 정확히 받아옵니다. 근데 왜 View를 엉뚱한 값을 받아올까요...
어디부분을 살펴봐야할까요?
제가 모르는 옵션같은게 있나요...?
알려주세요~~~~~

[ArrayAdapter부분]
public class ListArrayAdapter_lightNameEdit extends ArrayAdapter {
Context context;
private ArrayList items;
int rowlayoutResource;
int viewID;
private ArrayList items;
int rowlayoutResource;
int viewID;
public ListArrayAdapter_lightNameEdit(Context context,
int textViewResourceId, ArrayList objects) {
super(context, textViewResourceId, objects);
// TODO Auto-generated constructor stub
this.context = context;
this.rowlayoutResource = textViewResourceId;
this.items = objects;
}
int textViewResourceId, ArrayList objects) {
super(context, textViewResourceId, objects);
// TODO Auto-generated constructor stub
this.context = context;
this.rowlayoutResource = textViewResourceId;
this.items = objects;
}
@Override
public View getView(int position, final View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View row = convertView;
if(row == null)
{
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = inflater.inflate(rowlayoutResource, null);
}
String temp = (String)items.get(position);
EditText editBox = (EditText)row.findViewById(R.id.editLightName_row);
editBox.setText(temp);
return row;
}
}
[ItemClickListener부분]
AdapterView.OnItemClickListener mItemClickListener = new OnItemClickListener()
{
public void onItemClick(AdapterView<?> adapter, View view, int Pos, long arg3)
{
EditText editBox = (EditText)view.findViewById(R.id.editLightName_row);
editBox.setBackgroundResource(R.drawable.input_change);
............
{
public void onItemClick(AdapterView<?> adapter, View view, int Pos, long arg3)
{
EditText editBox = (EditText)view.findViewById(R.id.editLightName_row);
editBox.setBackgroundResource(R.drawable.input_change);
............
...........




저도 자세히는 모르지만....리스트 내에서 각 아이템의 numbering 은 focus 를 중심으로 가변적인걸로 알고 있습니다.
저의 경우에는 해당 버튼의 클릭리스너를 getView 안에서 생성 했고요...해당 view 에 setTag 로 position 값을 등록 후
리스너 안에서 getTag 를 통해 position 값을 찾아 사용 했습니다.