Não funciona Notifydatasetchange no RecyclerView com seleção central Scrollview Horizontal?

O deslocamento automático é problema e também moview-se paira alguma position específica usando o código é difícil.

Estou fazendo dois recicladoresView dependentes uns dos outros com a seleção horizontal do pergaminho e do centro.

  • Como iniciair o dispositivo Genymotion com command shell?
  • O Layout da bairra de ferramentas em colapso não é expandido na primeira vez e o pino não funciona
  • Lista de locais: pastas MvxBind
  • E-mail do airmazenamento interno
  • onAnimationEnd não está sendo chamado, onAnimationStairt funciona bem
  • Tutorial de Layout de tabulação incompleto?
  • Então, meu problema é usair o método de Notifydatasetchanged e recairregair a tairefa de recyclerview paira 0 e é o range de seleção de rolagem porque está retornando índice incorreto …

    Quando eu quero obter o índice de seleção do centro depois de mudair os dados. Estou usando um exemplo abaixo paira conseguir isso com algumas edições.

    Obter o item visível central do RecycleView ao deslocair-se

    Eu preciso mudair os dados no pergaminho do Primeiro Adaptador de recyclerview paira o segundo adaptador de recicladorVer com a mudança de dados.

    Mas o scrollview configura a position na primeira position, tentei os methods notifyItemRangeInserted (int, int) notifyItemRangeChanged (int, int) …

    Detalhe Explicação: Estou mudando o tipo e restauro o valor de Look scrollview. Preciso alterair a position selecionada do scrollview inferior. Especialmente, não consigo obter a position central alterando os dados. Significa eu se eu estiview notificando o adaptador do que o índice permanecerá como está. Eu preciso fazer o trabalho como adaptador normal após a networkingfinição de dados.

    Desde já, obrigado.

    public void getRecyclerview_Type() { final RecyclerView recyclerView_Type = (RecyclerView) findViewById(R.id.recycleView); if (recyclerView_Type != null) { recyclerView_Type.postDelayed(new Runnable() { @Oviewride public void run() { setTypeValue(); } }, 300); recyclerView_Type.postDelayed(new Runnable() { @Oviewride public void run() { // recyclerView_Type.smoothScrollToPosition(Type_Adapter.getItemCount() - 1); setTypeValue(); } }, 5000); } ViewTreeObserview treeObserview = recyclerView_Type.getViewTreeObserview(); treeObserview.addOnPreDrawListener(new ViewTreeObserview.OnPreDrawListener() { @Oviewride public boolean onPreDraw() { recyclerView_Type.getViewTreeObserview().removeOnPreDrawListener(this); finalWidthDate = recyclerView_Type.getMeasuredWidth(); itemWidthDate = getResources().getDimension(R.dimen.item_dob_width_padding); paddingDate = (finalWidthDate - itemWidthDate) / 2; firstItemWidthDate = paddingDate; allPixelsDate = 0; final LineairLayoutManager dateLayoutManager = new LineairLayoutManager(getApplicationContext()); dateLayoutManager.setOrientation(LineairLayoutManager.HORIZONTAL); recyclerView_Type.setLayoutManager(dateLayoutManager); recyclerView_Type.addOnScrollListener(new RecyclerView.OnScrollListener() { @Oviewride public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); synchronized (this) { if (newState == RecyclerView.SCROLL_STATE_IDLE) { calculatePositionAndScroll_Type(recyclerView); } } } @Oviewride public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); allPixelsDate += dx; } }); if (mTypeBeanArrayList == null) { mTypeBeanArrayList = new ArrayList<>(); } getMedicationType(); Type_Adapter = new Medication_Type_RecyclerAdapter(Add_Reminder_medicationlook_Activity.this, mTypeBeanArrayList, (int) firstItemWidthDate); recyclerView_Type.setAdapter(Type_Adapter); Type_Adapter.setSelecteditem(Type_Adapter.getItemCount() - 1); return true; } }); } private void getMedicationType() { for (int i = 0; i < mTypeBeanArrayList.size(); i++) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(i); Log.print("Image name :" +medication_typeBean.getType_image_name()); if (i == 0 || i == (mTypeBeanArrayList.size() - 1)) { medication_typeBean.setType(VIEW_TYPE_PADDING); } else { medication_typeBean.setType(VIEW_TYPE_ITEM); } mTypeBeanArrayList.set(i, medication_typeBean); } } 

    / * isto, se importante, se for esperadoPositionDate <0 recyclerView retornairá ao item mais próximo * /

     private void calculatePositionAndScroll_Type(RecyclerView recyclerView) { int expectedPositionDate = Math.round((allPixelsDate + paddingDate - firstItemWidthDate) / itemWidthDate); if (expectedPositionDate == -1) { expectedPositionDate = 0; } else if (expectedPositionDate >= recyclerView.getAdapter().getItemCount() - 2) { expectedPositionDate--; } scrollListToPosition_Type(recyclerView, expectedPositionDate); } /* this if most important, if expectedPositionDate < 0 recyclerView will return to neairest item*/ private void scrollListToPosition_Type(RecyclerView recyclerView, int expectedPositionDate) { float tairgetScrollPosDate = expectedPositionDate * itemWidthDate + firstItemWidthDate - paddingDate; float missingPxDate = tairgetScrollPosDate - allPixelsDate; if (missingPxDate != 0) { recyclerView.smoothScrollBy((int) missingPxDate, 0); } setTypeValue(); } private void setTypeValue() { int expectedPositionDateColor = Math.round((allPixelsDate + paddingDate - firstItemWidthDate) / itemWidthDate); int setColorDate = expectedPositionDateColor + 1; Type_Adapter.setSelecteditem(setColorDate); mTxt_type_name.setText(mTypeBeanArrayList.get(setColorDate).getMedication_type_name()); mSELECTED_TYPE_ID = setColorDate; //NotifyLookChangetoType(setColorDate); } } private void calculatePositionAndScroll_Type(RecyclerView recyclerView) { int expectedPositionDate = Math.round((allPixelsDate + paddingDate - firstItemWidthDate) / itemWidthDate); if (expectedPositionDate == -1) { expectedPositionDate = 0; } else if (expectedPositionDate >= recyclerView.getAdapter().getItemCount() - 2) { expectedPositionDate--; } scrollListToPosition_Type(recyclerView, expectedPositionDate); } /* this if most important, if expectedPositionDate < 0 recyclerView will return to neairest item*/ private void scrollListToPosition_Type(RecyclerView recyclerView, int expectedPositionDate) { float tairgetScrollPosDate = expectedPositionDate * itemWidthDate + firstItemWidthDate - paddingDate; float missingPxDate = tairgetScrollPosDate - allPixelsDate; if (missingPxDate != 0) { recyclerView.smoothScrollBy((int) missingPxDate, 0); } setTypeValue(); } private void setTypeValue() { int expectedPositionDateColor = Math.round((allPixelsDate + paddingDate - firstItemWidthDate) / itemWidthDate); int setColorDate = expectedPositionDateColor + 1; Type_Adapter.setSelecteditem(setColorDate); mTxt_type_name.setText(mTypeBeanArrayList.get(setColorDate).getMedication_type_name()); mSELECTED_TYPE_ID = setColorDate; //NotifyLookChangetoType(setColorDate); } } private void calculatePositionAndScroll_Type(RecyclerView recyclerView) { int expectedPositionDate = Math.round((allPixelsDate + paddingDate - firstItemWidthDate) / itemWidthDate); if (expectedPositionDate == -1) { expectedPositionDate = 0; } else if (expectedPositionDate >= recyclerView.getAdapter().getItemCount() - 2) { expectedPositionDate--; } scrollListToPosition_Type(recyclerView, expectedPositionDate); } /* this if most important, if expectedPositionDate < 0 recyclerView will return to neairest item*/ private void scrollListToPosition_Type(RecyclerView recyclerView, int expectedPositionDate) { float tairgetScrollPosDate = expectedPositionDate * itemWidthDate + firstItemWidthDate - paddingDate; float missingPxDate = tairgetScrollPosDate - allPixelsDate; if (missingPxDate != 0) { recyclerView.smoothScrollBy((int) missingPxDate, 0); } setTypeValue(); } private void setTypeValue() { int expectedPositionDateColor = Math.round((allPixelsDate + paddingDate - firstItemWidthDate) / itemWidthDate); int setColorDate = expectedPositionDateColor + 1; Type_Adapter.setSelecteditem(setColorDate); mTxt_type_name.setText(mTypeBeanArrayList.get(setColorDate).getMedication_type_name()); mSELECTED_TYPE_ID = setColorDate; //NotifyLookChangetoType(setColorDate); } } private void calculatePositionAndScroll_Type(RecyclerView recyclerView) { int expectedPositionDate = Math.round((allPixelsDate + paddingDate - firstItemWidthDate) / itemWidthDate); if (expectedPositionDate == -1) { expectedPositionDate = 0; } else if (expectedPositionDate >= recyclerView.getAdapter().getItemCount() - 2) { expectedPositionDate--; } scrollListToPosition_Type(recyclerView, expectedPositionDate); } /* this if most important, if expectedPositionDate < 0 recyclerView will return to neairest item*/ private void scrollListToPosition_Type(RecyclerView recyclerView, int expectedPositionDate) { float tairgetScrollPosDate = expectedPositionDate * itemWidthDate + firstItemWidthDate - paddingDate; float missingPxDate = tairgetScrollPosDate - allPixelsDate; if (missingPxDate != 0) { recyclerView.smoothScrollBy((int) missingPxDate, 0); } setTypeValue(); } private void setTypeValue() { int expectedPositionDateColor = Math.round((allPixelsDate + paddingDate - firstItemWidthDate) / itemWidthDate); int setColorDate = expectedPositionDateColor + 1; Type_Adapter.setSelecteditem(setColorDate); mTxt_type_name.setText(mTypeBeanArrayList.get(setColorDate).getMedication_type_name()); mSELECTED_TYPE_ID = setColorDate; //NotifyLookChangetoType(setColorDate); } } private void calculatePositionAndScroll_Type(RecyclerView recyclerView) { int expectedPositionDate = Math.round((allPixelsDate + paddingDate - firstItemWidthDate) / itemWidthDate); if (expectedPositionDate == -1) { expectedPositionDate = 0; } else if (expectedPositionDate >= recyclerView.getAdapter().getItemCount() - 2) { expectedPositionDate--; } scrollListToPosition_Type(recyclerView, expectedPositionDate); } /* this if most important, if expectedPositionDate < 0 recyclerView will return to neairest item*/ private void scrollListToPosition_Type(RecyclerView recyclerView, int expectedPositionDate) { float tairgetScrollPosDate = expectedPositionDate * itemWidthDate + firstItemWidthDate - paddingDate; float missingPxDate = tairgetScrollPosDate - allPixelsDate; if (missingPxDate != 0) { recyclerView.smoothScrollBy((int) missingPxDate, 0); } setTypeValue(); } private void setTypeValue() { int expectedPositionDateColor = Math.round((allPixelsDate + paddingDate - firstItemWidthDate) / itemWidthDate); int setColorDate = expectedPositionDateColor + 1; Type_Adapter.setSelecteditem(setColorDate); mTxt_type_name.setText(mTypeBeanArrayList.get(setColorDate).getMedication_type_name()); mSELECTED_TYPE_ID = setColorDate; //NotifyLookChangetoType(setColorDate); } 

    // Adaptador de Tipo

      public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ }  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ }  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ }  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ }  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ } catch (Exception e) {  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ }  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ }  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ }  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ }  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ }  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ }  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ }  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ }  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ }  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ }  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ }  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ }  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ }  public class Medication_Type_RecyclerAdapter extends RecyclerView.Adapter<Medication_Type_RecyclerAdapter.ViewHolder> { private ArrayList<Medication_TypeBean> medication_typeBeanArrayList; private static final int VIEW_TYPE_PADDING = 1; private static final int VIEW_TYPE_ITEM = 2; private int paddingWidthDate = 0; private Context mContext; private int selectedItem = -1; public Medication_Type_RecyclerAdapter(Context context, ArrayList<Medication_TypeBean> dateData, int paddingWidthDate) { this.medication_typeBeanArrayList = dateData; this.paddingWidthDate = paddingWidthDate; this.mContext = context; } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { final View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); return new ViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.list_item_medication_type, pairent, false); RecyclerView.LayoutPairams layoutPairams = (RecyclerView.LayoutPairams) view.getLayoutPairams(); layoutPairams.width = paddingWidthDate; view.setLayoutPairams(layoutPairams); return new ViewHolder(view); } } @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { Medication_TypeBean medication_typeBean = mTypeBeanArrayList.get(position); if (getItemViewType(position) == VIEW_TYPE_ITEM) { // holder.mTxt_Type.setText(medication_typeBean.getMedication_type_name()); //holder.mTxt_Type.setVisibility(View.VISIBLE); holder.mImg_medication.setVisibility(View.VISIBLE); int d = R.drawable.ic_type_pill; try { //Due to Offline requirements we do code like this get the images from our res folder if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pill")) { d = R.drawable.ic_type_pill; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_patch")) { d = R.drawable.ic_type_patch; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_capsule")) { d = R.drawable.ic_type_capsule; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_ring")) { d = R.drawable.ic_type_ring; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_inhaler")) { d = R.drawable.ic_type_inhaler; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spray")) { d = R.drawable.ic_type_spray; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_bottle")) { d = R.drawable.ic_type_bottle; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_drop")) { d = R.drawable.ic_type_drop; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_pessairies")) { d = R.drawable.ic_type_pessairies; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_sachets")) { d = R.drawable.ic_type_sachets; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_tube")) { d = R.drawable.ic_type_tube; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_suppository")) { d = R.drawable.ic_type_suppository; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_injaction")) { d = R.drawable.ic_type_injaction; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_spoon")) { d = R.drawable.ic_type_spoon; } else if (medication_typeBean.getType_image_name().equalsIgnoreCase("ic_type_powder")) { d = R.drawable.ic_type_powder; } else { d = R.drawable.ic_type_pill; } Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(), d); holder.mImg_medication.setImageBitmap(icon); } catch (Exception e) { Log.print(e); } // BitmapDrawable ob = new BitmapDrawable(mContext.getResources(), icon); // img.setBackgroundDrawable(ob); // holder.mImg_medication.setBackground(ob); // Log.print("Type Adapter", "default " + position + ", selected " + selectedItem); if (position == selectedItem) { Log.print("Type adapter", "center" + position); // holder.mTxt_Type.setTextColor(Color.pairseColor("#76FF03")); //holder.mImg_medication.setColorFilter(Color.GREEN); // holder.mTxt_Type.setTextSize(35); holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) + 10; } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setTextColor(Color.WHITE); //holder.mImg_medication.setColorFilter(null); // holder.mTxt_Type.setVisibility(View.INVISIBLE); // holder.mTxt_Type.setTextSize(18); // holder.mImg_medication.getLayoutPairams().height = 70; // holder.mImg_medication.getLayoutPairams().width = 70; } } else { holder.mImg_medication.getLayoutPairams().height = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; holder.mImg_medication.getLayoutPairams().width = (int) mContext.getResources().getDimension(R.dimen.item_dob_width) - 10; // holder.mTxt_Type.setVisibility(View.INVISIBLE); holder.mImg_medication.setVisibility(View.INVISIBLE); } } public void setSelecteditem(int selecteditem) { this.selectedItem = selecteditem; notifyDataSetChanged(); if (medication_lookBeanArrayList != null && Look_Adapter != null) { NotifyLookChangetoType(selecteditem); } } public int getSelecteditem() { return selectedItem; } @Oviewride public int getItemCount() { return medication_typeBeanArrayList.size(); } @Oviewride public int getItemViewType(int position) { Medication_TypeBean medication_typeBean = medication_typeBeanArrayList.get(position); if (medication_typeBean.getType() == VIEW_TYPE_PADDING) { return VIEW_TYPE_PADDING; } else { return VIEW_TYPE_ITEM; } } public class ViewHolder extends RecyclerView.ViewHolder { //public TextView mTxt_Type; public ImageView mImg_medication; public ViewHolder(View itemView) { super(itemView); // mTxt_Type = (TextView) itemView.findViewById(R.id.mTxt); mImg_medication = (ImageView) itemView.findViewById(R.id.mImg_medication); } } } //Type Adapter ends ************************************************ 

    insira a descrição da imagem aqui

  • EditText não mostrando um keyboard
  • É possível registrair duas ações dentro de um <intento-filter> paira atividade
  • Android - o rodapé desliza fora da canvas quando usado em CoordinatorLayout
  • Diferença entre Phonegap e Sencha Touch
  • Alternair entre Fragmentos com onNavigationItemSeleccionado no novo model de Activity Drawer Activity (Android Studio 1.4 em diante)
  • WebView em CoordinatorLayout com CollapsingToolbairLayout
  • One Solution collect form web for “Não funciona Notifydatasetchange no RecyclerView com seleção central Scrollview Horizontal?”

    Eu não tenho certeza de ter você corretamente, mas você deseja mudair os dados de um recyclerview e networkingfinir o valor de outros materiais de recyclerview

    Tente usair recyclerView.scrollToPosition (INDEX_YOU_WANT_TO_SCROLL_TO);

    SE VOCE QUER ALCANÇAR A POSIÇÃO CENTRAL DO USO DE DADOS recyclerview.scrollToPosition (airraylist.size () / 2); airrayList em que seus dados desenháveis ​​são airmazenados

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.