I'm working on android app that creat layout with textView & checkbox programmatically for each text user input in EditText, and when the user select one of the checkbox and click on delete button the layout that contain that checkbox remove from the main layout. But when I click on delete button just the last layout removed, and that not what I want.
public void plusBtn(View view) { item = actv.getText().toString(); // text from EditText actv.setText(""); creatt(); } public void deletBtn(View view) { if(chbox.isChecked()){ linear.removeView(linr); } } public void creatt() { linr = new LinearLayout(this); linr.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); linr.setOrientation(LinearLayout.HORIZONTAL); linr.setGravity(Gravity.RIGHT); TextView txt = new TextView(this); txt.setText(item); linr.addView(txt); chbox = new CheckBox(this); linr.addView(chbox); linear.addView(linr); // main layout }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)