Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What I understand of the question:</p> <ol> <li>You need to add a new row on a button click, new row should be the first one to be displayed. The new row will have some default values.</li> <li>There is a button in each row called <code>remove</code>, onClick you need to remove that row.</li> </ol> <p>If I am correct, here are the answers (presuming you know <a href="https://stackoverflow.com/questions/6372104/best-practice-for-defining-button-events-in-android">how to assign eventhandler to buttons</a>):</p> <ol> <li><p>I would suggest to use an ArrayList to get the adapter and then populate it. On row add, insert at begining the data to be inserted in a new row using <a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/util/ArrayList.html#add%28int,%20java.lang.Object%29" rel="nofollow noreferrer">add</a> and then get the adapter and populate listview. Make the listview an instance variable.</p></li> <li><p>You may want to check out <a href="https://stackoverflow.com/questions/5559941/view-events-inside-a-listview-row">a previous sof question on assigning eventhandlers to views inside a row</a> or <a href="https://stackoverflow.com/questions/3851802/android-add-event-listeners-to-every-item-in-a-listview">this sof question on same topic</a> for assiging the event. For deleting, use <a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/util/ArrayList.html#remove%28int%29" rel="nofollow noreferrer">remove</a> method of arraylist with index that of the selected row. Remove the element, form new adapter and populate the listview.</p></li> </ol>
    singulars
    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.
    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