private void initItemView(SettingViewItemData data, final int index) {
    FrameLayout itemView = data.getItemView();

    if (itemView instanceof SwitchItemView) {
      ((SwitchItemView) itemView).fillData(data.getData());
      ((SwitchItemView) itemView)
          .setOnSwitchItemChangedListener(
              new onSwitchItemChangedListener() {

                @Override
                public void onSwitchItemChanged(boolean isChecked) {
                  // TODO Auto-generated method stub
                  if (null != mItemSwitchListener) {
                    mItemSwitchListener.onSwitchChanged(index, isChecked);
                  }
                }
              });
      itemView.setClickable(false);
    } else {
      itemView.setClickable(data.isClickable());
      itemView.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              // TODO Auto-generated method stub
              if (null != mItemClickListener) {
                mItemClickListener.onItemClick(index);
              }
            }
          });

      if (itemView instanceof BasicItemViewH) {
        ((BasicItemViewH) itemView).fillData(data.getData());
      } else if (itemView instanceof BasicItemViewV) {
        ((BasicItemViewV) itemView).fillData(data.getData());
      } else if (itemView instanceof ImageItemView) {
        ((ImageItemView) itemView).fillData(data.getData());
      } else if (itemView instanceof CheckItemViewH) {
        ((CheckItemViewH) itemView).fillData(data.getData());
      } else if (itemView instanceof CheckItemViewV) {
        ((CheckItemViewV) itemView).fillData(data.getData());
      }
    }

    int height =
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_PX,
                getResources().getDimensionPixelSize(R.dimen.setting_view_min_height),
                getResources().getDisplayMetrics());
    LinearLayout.LayoutParams lps =
        new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, height);

    addView(itemView, lps);
  }
 public void modifySubTitle(String subTitle, int index) {
   FrameLayout itemView = getItemView(index);
   if (itemView instanceof BasicItemViewH) {
     ((BasicItemViewH) itemView).getmSubTitle().setText(subTitle);
   } else if (itemView instanceof BasicItemViewV) {
     ((BasicItemViewV) itemView).getmSubTitle().setText(subTitle);
   } else if (itemView instanceof CheckItemViewV) {
     ((CheckItemViewV) itemView).getmSubTitle().setText(subTitle);
   }
 }
 public void modifyDrawable(Drawable drawable, int index) {
   FrameLayout itemView = getItemView(index);
   if (itemView instanceof SwitchItemView) {
     ((SwitchItemView) itemView).getmDrawable().setImageDrawable(drawable);
   } else {
     if (itemView instanceof BasicItemViewH) {
       ((BasicItemViewH) itemView).getmDrawable().setImageDrawable(drawable);
     } else if (itemView instanceof BasicItemViewV) {
       ((BasicItemViewV) itemView).getmDrawable().setImageDrawable(drawable);
     } else if (itemView instanceof ImageItemView) {
       ((ImageItemView) itemView).getmDrawable().setImageDrawable(drawable);
     } else if (itemView instanceof CheckItemViewH) {
       ((CheckItemViewH) itemView).getmDrawable().setImageDrawable(drawable);
     } else if (itemView instanceof CheckItemViewV) {
       ((CheckItemViewV) itemView).getmDrawable().setImageDrawable(drawable);
     }
   }
 }
 public void modifyTitle(String title, int index) {
   FrameLayout itemView = getItemView(index);
   if (itemView instanceof SwitchItemView) {
     ((SwitchItemView) itemView).getmTitle().setText(title);
   } else {
     if (itemView instanceof BasicItemViewH) {
       ((BasicItemViewH) itemView).getmTitle().setText(title);
     } else if (itemView instanceof BasicItemViewV) {
       ((BasicItemViewV) itemView).getmTitle().setText(title);
     } else if (itemView instanceof ImageItemView) {
       ((ImageItemView) itemView).getmTitle().setText(title);
     } else if (itemView instanceof CheckItemViewH) {
       ((CheckItemViewH) itemView).getmTitle().setText(title);
     } else if (itemView instanceof CheckItemViewV) {
       ((CheckItemViewV) itemView).getmTitle().setText(title);
     }
   }
 }