2016-12-01 7 views
0

RecyclerViewアダプタを割り当ててアイテム装飾を追加することもできますが、アダプタはビューを作成しません。私はアイテムの装飾を削除したときにその建物の罰金。私がRecyclerViewを作成したxmlのコードを問題なく使用したので、アイテムの装飾に問題はありません。アダプタは、アイテム装飾を追加した後、プログラムで作成されたリサイクラビューでビューを作成しません

サンプルコードは以下の通りです:

RecyclerView recyclerView = new RecyclerView(context); 
LinearLayout.LayoutParams recyclerViewLayoutParams = 
     new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT); 
recyclerViewLayoutParams.gravity = Gravity.START; 
recyclerView.setLayoutParams(recyclerViewLayoutParams); 
recyclerView.setClipToPadding(false); 
ll_parent_layout.addView(recyclerView); 
LinearLayoutManager layoutManager = new LinearLayoutManager(getParent()); 
recyclerView.setLayoutManager(layoutManager); 
recyclerView.setNestedScrollingEnabled(false); 
recyclerView.setHasFixedSize(false); 

// recyclerView.removeItemDecoration(gridSpacingItemDecoration); 
// recyclerView.addItemDecoration(gridSpacingItemDecoration); 

Adapter adapter = new Adapter(Activity.this, ResponseMap); 

// linearSpacingItemDecoration = new LinearSpacingItemDecoration(R.dimen.margin8, adapter.getItemCount()); 
// recyclerView.removeItemDecoration(linearSpacingItemDecoration); 
// recyclerView.addItemDecoration(linearSpacingItemDecoration); 
recyclerView.setAdapter(adapter); 
+0

がrecyclerView.setAdapter方法でいくつかの時間後で考え出していましたか? – Drim

+0

あなたのアイテムの装飾は何ですか?あなたは、アイテムの装飾は、リストアイテムのコンテンツビュー – Bhargav

+0

を超えて**描画することを覚えておく必要があります@Drimそれはコード内にあります。私は貼り付けるのを忘れてしまった。 –

答えて

0

問題は、アイテムデコレータクラスが初期化され、reinitialzedなったか..私は

関連する問題