Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Does the following class correspond to what you need ?</p> <pre><code>public class DoubleListView extends LinearLayout { private Button button; public final ListView list1, list2; public DoubleListView(Context context) { super(context); setOrientation(VERTICAL); list1 = new ListView(context); addView(list1, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1)); list2 = new ListView(context); addView(list2, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1)); button = new Button(context); addView(button, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); // Initial state list2.setVisibility(View.GONE); updateContent(); } private void updateContent() { if(list2.getVisibility() == View.VISIBLE) { button.setText("REMOVE"); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { list2.setVisibility(View.GONE); updateContent(); } }); } else { button.setText("ADD"); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { list2.setVisibility(View.VISIBLE); updateContent(); } }); } } } </code></pre> <p>You can use it in a sample activity like this:</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); DoubleListView dbleListView = new DoubleListView(this); dbleListView.list1.setBackgroundColor(Color.RED); dbleListView.list2.setBackgroundColor(Color.BLUE); setContentView(dbleListView); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload