2014-06-23 1 views
0

저는 iOS 개발자 였고 Android 프로젝트를 시작으로 작업했습니다. 하루 동안 다음 호에 갇혔습니다. 도움을 좀주세요.커서에 데이터가 있지만 ListFragment가 빈보기 만 표시합니다.

another stack question으로 복제 될 수도 있지만 아무도 그 질문에 답변하지 않았습니다.

내 문제는 다음 코드에서 발생했습니다. log.d는 실제로 커서에 데이터가 있음을 나타내지 만 listfragment는 항상 빈 뷰를 표시합니다. enter image description here

여기가 ImagesListAdapter

public class ImagesListAdapter extends SimpleCursorAdapter { 
     private static final String TAG = ImagesListAdapter.class.getSimpleName(); 
     static final String[] from = new String[] {ImageData.C_LINK_URL }; 
     static final int[] to = new int[] { R.id.coupon_lbl}; 


// Constructor 
public ImagesListAdapter(Context context, Cursor c) { 
    super(context, R.layout.image_cell, c, from, to, 0); 
} 
// This is where the actual binding of a cursor to view happens 
@Override 
public void bindView(View row, Context context, Cursor cursor) { 
    super.bindView(row, context, cursor); 
    // Manually bind created at timestamp to its view 
    Log.d(TAG,"binding View."); 

    String link = cursor.getString(cursor.getColumnIndex(ImageData.C_LINK_URL)); 
    TextView textCreatedAt = (TextView) row.findViewById(R.id.coupon_lbl); 
    textCreatedAt.setText(link); 
} 

}

나는이 디버깅을 시작하여야에게 무엇입니까?

+0

ImagesListAdapter의 우편 번호. –

+0

안녕하세요, Giru Bhai, 몇 가지 코드로 질문을 업데이트했습니다. 회신 해 주셔서 감사합니다. –

+0

'super.bindView'가 이미 텍스트를 설정해야합니다. 왜 그것을 무시하고 슈퍼 콜 후에 수동으로 설정하려고합니까? 또한,'bindView'가 호출되고 있는지 확인하고'row.findViewById'를 호출 할 때 textview가 반환되고 image_cell 레이아웃에 포함되어 있는지 확인하십시오. – Chris

답변

0

코드가 모두 멋지게 보이고 내 친구 중 하나가 IDE에서 코드를 실행하고 setListAdapter()를 "onCreateView"로 옮겼습니다. 작동합니다. 그러나, 내가 똑같이했을 때 나는 아무것도 얻지 못했다. 정말 이상합니다 ...

나는이 시점에서 ListActivity를 사용하기로 결정했으며 모든 것이 예상대로 작동합니다.

귀하의 도움과 제안에 감사드립니다.

관련 문제