@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int itemViewType) { View convertView = null; Context context = parent.getContext(); if (type == RosterHelper.ACTIVE_CONTACTS) { convertView = new RosterItemView(SawimApplication.getInstance().getBaseContext()); } if (itemViewType == ITEM_PROTOCOL) { convertView = new LinearLayout(context); RosterItemView rosterItemView = new RosterItemView(context); MyImageButton imageButton = new MyImageButton(context); ProgressBar progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleInverse); LinearLayout.LayoutParams progressLinearLayout = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); progressLinearLayout.gravity = Gravity.RIGHT; progressBar.setLayoutParams(progressLinearLayout); progressBar.setMax(100); LinearLayout.LayoutParams buttonLinearLayout = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); buttonLinearLayout.gravity = Gravity.RIGHT; imageButton.setLayoutParams(buttonLinearLayout); LinearLayout.LayoutParams rosterLinearLayout = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); rosterLinearLayout.gravity = Gravity.LEFT; rosterLinearLayout.weight = 1; convertView.setBackgroundColor(Scheme.getColor(R.attr.item_selected)); rosterItemView.setLayoutParams(rosterLinearLayout); imageButton.setImageDrawable(SawimResources.MENU_ICON); ((ViewGroup) convertView).setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); ((ViewGroup) convertView).addView(rosterItemView); ((ViewGroup) convertView).addView(progressBar); ((ViewGroup) convertView).addView(imageButton); } if (itemViewType == ITEM_GROUP) { convertView = new RosterItemView(SawimApplication.getInstance().getBaseContext()); } if (itemViewType == ITEM_CONTACT) { convertView = new RosterItemView(SawimApplication.getInstance().getBaseContext()); } return new ViewHolder(convertView); }