I decided on my own, so this is a working solution for an extensible layout.
Using:
addAction(YourLayout, LayoutToBeExpanded)
Functions:
public void addAction(final View layout, final View summary) { layout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (summary.getVisibility() == View.GONE) { expand(summary); } else { collapse(summary); } } }); } private void expand(View summary) {
If you also want to collapse "mLayoutToBeExpanded" when configuring yourself, use this:
public void addAction(final View layout, final View summary) { layout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (summary.getVisibility() == View.GONE) { expand(summary); } else { collapse(summary); } } }); summary.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (summary.getVisibility() == View.VISIBLE) { collapse(summary); } else {
source share