0
사용자 지정 어댑터를 사용하는 목록보기가 있습니다. 어댑터에는 항목 목록에 17 개의 항목이 있지만 처음 2 개만 표시됩니다. getView()
을 추적하고 위치 0과 1에 대해서만 호출되었음을 확인했습니다.모든 항목에 대해 getView() 어댑터가 호출되지 않음
어댑터를 채우고 그 중 onCreate()
학부모 Activity
.
FavouritesListAdapter adapter = new FavouritesListAdapter(favourites, this);
((ListView) findViewById(R.id.list)).setAdapter(adapter);
adapter.notifyDataSetChanged(); // not needed but put here out of desperation!
어댑터 서명 getView()
방법
public class FavouritesListAdapter extends BaseAdapter {
private Context context;
private ArrayList<Favourite> entries;
public FavouritesListAdapter(ArrayList<Favourite> favourites, Context context) {
this.entries = favourites;
this.context = context;
}
public View getView(int position, View convertView, ViewGroup parent) {
RelativeLayout rl;
Log.d(LOG_DEBUG_TAG, "Count:" + getCount() ", asking for pos " + position);
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
rl = (RelativeLayout) inflater.inflate(R.layout.favourite_tide_table, null);
convertView = rl;
} else { // convertView is not null (it's being recycled)
Favourite thisFavourite = this.getItem(position);
convertView = thisFavourite.getPortView();
}
return convertView;
}
로그 캣 출력 :
가Count:17, asking for pos 0
Count:17, asking for pos 0
Count:17, asking for pos 0
Count:17, asking for pos 1
Count:17, asking for pos 0
Count:17, asking for pos 0
액티비티 XML :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/list"
android:background="@color/white"
android:cacheColorHint="#00000000"
android:divider="#FF0000"
android:dividerHeight="1px"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</ScrollView>
처음 두 항목이 제대로 DIS 연주.
내가 무엇을 놓쳤는가? 감사!
화면에 얼마나 많은 행이 있습니까? – Blackbelt
은 scrollview에 listview를 넣지 않습니다. 작동하지 않습니다. – njzk2
@ njzk2 Doh, doh, doh! 나는 얼마나 어리석은 지 믿을 수 없다! 얼마나 많은 목록보기를 수행 했습니까? 감사. 담당자를 원하면 답변으로 의견을 게시하십시오 (어쨌든 미래의 방문자에게 유용함). 동의하겠습니다. 건배 – Simon