2013-09-02 4 views
0

MergeAdapter를 사용하여 섹션 헤더가있는 목록을 표시합니다. 이 목록은 잘 표시되지만 때로는 안되는 경우 getView 메소드 내부의 특정 사항이 트리거되는 경우가 있습니다.MergeAdapter 잘못된 시간에 특정 문장 실행

여기에 트리거가 발생했습니다.

@Override 
public View getView(int position, View convertView, ViewGroup parent) 
{ 
    ... 
    try { 
     JSONObject thisRow = items.get(position); 
     ... 
     View.OnClickListener myListener = new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 
       Toast.makeText(getContext(), ID, Toast.LENGTH_SHORT).show(); 
      } 
     }; 

     JSONObject alterations = thisRow.getJSONArray("alteration").getJSONObject(0); 


     // This if statement gets trigger when it shouldn't 
     if (!alterations.getString("text").equals("false")) { 
      CharSequence currText = time.getText(); 
      time.setText(currText+" vs" +ID); 
      Log.d("FUApp", "Alterations 'text' isn't false at "+ID); 
      Button alter = (Button) centreView.findViewById(R.id.is_alt); 
      String s = String.valueOf(position); 
      alter.setText(s); 
      RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); 
      alter.setLayoutParams(lp); 
      alter.setOnClickListener(myListener); 
     } 
    ... 
    return centreView; 
} 

위치 값을 표시하는 레이블을 설정하고 여기에 내 앱에서 화면 캡처를 설정합니다.

enter image description here

버튼이 위치 (43) 인 표시되는 버튼이 전혀 표시되지 않아야 볼 수 있듯이.

나는 왜 이런 일이 일어나고 있는지 완전히 이해하기가 어렵습니다. 아무도 내가 이것을 알아낼 수있게 도와 줄 수 있습니까?

EDIT : 위치 (예 : 35)에서보기를 떠날 때 화면에 들어가는 행에서 if 문이 트리거되는 것으로 보입니다. 아직 어떻게 멈추는 지 아직 확실하지 않습니다.

답변

0

이전 답변을 삭제했는데 전혀 좋지 않았습니다. 내가 문제를 일으켰다. 보기 내가

내가이 라인을
Button alter = (Button) centreView.findViewById(R.id.is_alt); 
     RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, 0); 
     alter.setLayoutParams(lp); 
     final JSONObject alterations = thisRow.getJSONArray("alteration").getJSONObject(0); 
     if (!alterations.getString("text").equals("false")) { 

을 추가 0dp 다시 버튼을 재설정하지 않은 재활용 될 때

문제

이었다 그리고 지금 정상적으로 작동합니다.