3 回答
TA贡献1788条经验 获得超4个赞
RecyclerView.Adapter
@Overridepublic int getItemCount() {
return 0;}@Overridepublic int getItemCount() {
return artists.size();}//correctLayoutInflater.from(parent.getContext()) .inflate(R.layout.card_listitem, parent, false);//incorrect (what I had)LayoutInflater.from(parent.getContext()) .inflate(R.layout.card_listitem,null);
RecyclerView
<android.support.v7.widget.RecyclerView android:id="@+id/RecyclerView" android:layout_width="match_parent" android:layout_height="match_parent" />
<view android:id="@+id/RecyclerView" class="android.support.v7.widget.RecyclerView" android:layout_width="match_parent" android:layout_height="match_parent" />
TA贡献1820条经验 获得超9个赞
RecyclerView mRecycler = (RecyclerView) this.findViewById(R.id.yourid);mRecycler.setAdapter(adapter);
adapter.notifyDataStateChanged();
public RecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.mObserver = new RecyclerView.RecyclerViewDataObserver(null);
this.mRecycler = new RecyclerView.Recycler();
this.mUpdateChildViewsRunnable = new Runnable() {
public void run() {
if(RecyclerView.this.mFirstLayoutComplete) {
if(RecyclerView.this.mDataSetHasChangedAfterLayout) {
TraceCompat.beginSection("RV FullInvalidate");
RecyclerView.this.dispatchLayout();
TraceCompat.endSection();
} else if(RecyclerView.this.mAdapterHelper.hasPendingUpdates()) {
TraceCompat.beginSection("RV PartialInvalidate");
RecyclerView.this.eatRequestLayout();
RecyclerView.this.mAdapterHelper.preProcess();
if(!RecyclerView.this.mLayoutRequestEaten) {
RecyclerView.this.rebindUpdatedViewHolders();
}
RecyclerView.this.resumeRequestLayout(true);
TraceCompat.endSection();
}
}
}
};void dispatchLayout() {
if(this.mAdapter == null) {
Log.e("RecyclerView", "No adapter attached; skipping layout");
} else if(this.mLayout == null) {
Log.e("RecyclerView", "No layout manager attached; skipping layout");
} else {TA贡献1835条经验 获得超7个赞
onCreate()ResultCallback
FragmentResultCallbackonConnected()
LinearLayoutManager llm = new LinearLayoutManager(this);llm.setOrientation(LinearLayoutManager.VERTICAL);list.setLayoutManager(llm); list.setAdapter( adapter );
- 3 回答
- 0 关注
- 712 浏览
添加回答
举报
