私はrecyclerviewでナビゲーション・ドロワーを作成していましたが、次に、recyclerviewの選択/クリックされた行を強調表示する必要がありました。 addOnItemTouchListener
の中に.setBackgroundColor(Color.GRAY)
を入れました。 それは動作しますが、特定の行数の後でバックグラウンドカラープロパティが繰り返されます... どうすれば解決できますか?あなたは、あなたがやっている内容を正確に把握しない限り、事前に おかげで...特定の行数の後にrecyclerview行プロパティを繰り返しますか?
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
View child = rv.findChildViewUnder(e.getX(), e.getY());
if(child != null && gestureDetector.onTouchEvent(e)) {
int position = rv.getChildAdapterPosition(child);
DrawerItem model = mDrawerItemList.get(position);
child.setBackgroundColor(Color.GRAY);
drawerLayout.closeDrawers();
Toast.makeText(RecyclerNavigationActivity.this,String.valueOf(position),Toast.LENGTH_SHORT).show();
}
return false;
}
これは機能しています、ありがとうPawelo .. –