0

I would like to add two buttons in my listview. Two button edit and delete for my list. I have already traveled the other posts on this subject but I still can not :(. I have already created a custom listview. I am a beginner so I have a hard time understanding. This would be nice a little help. Here is my code

My current listview

public class liste_offre extends AppCompatActivity {
DatabaseHelper myDb;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.liste_offre);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    ListView listView = (ListView) findViewById(R.id.List_offre);
    myDb = new DatabaseHelper(this);

    ArrayList<String> theList = new ArrayList<>();
    Cursor res = myDb.getAllData();
    if (res.getCount()==0){
        Toast.makeText(liste_offre.this,"Liste vide",Toast.LENGTH_LONG).show();
    }else {
        while (res.moveToNext()){
            theList.add(res.getString(1));
            ListAdapter listAdapter = new ArrayAdapter<>(this,android.R.layout.simple_list_item_1,theList);
            listView.setAdapter(listAdapter);
        }
    }
}

}

1 Answers1

0

Please refer the below post it may be exactly what you want

ListView with Add and Delete Buttons in each Row in android

Hope this helps you.

Community
  • 1
  • 1
Gaurav
  • 44
  • 5