Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to remove dynamically created layout
    primarykey
    data
    text
    <p>In my app i was created linear layout dynamically. That layout contains a text view and a button. Text view text was set using array list named as contact name. While clicking button i want to remove corresponding layout and remove element from array list at position'i'.</p> <pre><code> final LinearL ArrayList&lt;String&gt; contact_name = new ArrayList&lt;String&gt;(); final LinearLayout lab_linear = (LinearLayout) findViewById(R.id.contact_list_layout); lab_linear.setOrientation(LinearLayout.VERTICAL); for (i = 0; i &lt; Size_contact; i++) { final LinearLayout layout = new LinearLayout(this); layout.setId(i); layout.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(5, 5, 0, 0); layout.setLayoutParams(layoutParams); Resources res = getResources(); Drawable drawable = res.getDrawable(R.drawable.searchbox); layout.setBackgroundDrawable(drawable); final TextView Questions_value = new android.widget.TextView( getApplicationContext()); LinearLayout.LayoutParams layoutParams_text = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); layoutParams_text.setMargins(10, 5, 10, 2); Questions_value.setLayoutParams(layoutParams_text); Questions_value.setText(contact_name.get(i)); Questions_value.setTextSize(18); Questions_value.setId(i); layout.addView(Questions_value); final Button myButton = new Button(this); myButton.setId(i); myButton.setBackgroundResource(R.drawable.close); myButton.setLayoutParams(new LayoutParams(20, 20)); layout.addView(myButton); lab_linear.addView(layout); myButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int id = myButton.getId(); contact_name.remove(id); } }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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