private View initializeButton(int expandableItemPosition) { ExpandableItem expandableItem = expandableItems.get(expandableItemPosition); View button = null; Context context = getContext(); LayoutInflater layoutInflater = LayoutInflater.from(context); if (expandableItem.hasTitle()) { button = layoutInflater.inflate(R.layout.expandable_item_button, this, false); } else { button = layoutInflater.inflate(R.layout.expandable_item_image_button, this, false); } int visibility = expandableItemPosition == 0 ? View.VISIBLE : View.INVISIBLE; button.setVisibility(visibility); return button; }
private void configureButtonContent(View button, ExpandableItem expandableItem) { if (expandableItem.hasBackgroundId()) { int backgroundId = expandableItem.getBackgroundId(); button.setBackgroundResource(backgroundId); } if (expandableItem.hasTitle()) { String text = expandableItem.getTitle(); ((Button) button).setText(text); } if (expandableItem.hasResourceId()) { ImageButton imageButton = (ImageButton) button; int resourceId = expandableItem.getResourceId(); imageButton.setImageResource(resourceId); } }