Home  >  Forum  >  Android
Post New Query

Android ListView delete item and refresh

Asked on August 12, 2015
I have ListView in which I need to delete item one by one. How to get row id to delete it and then refresh the ListView.

Replied on August 13, 2015
  In your BaseAdapter sub class within  getView() method perform the delete operation.

    public View getView(final int position, View view, ViewGroup parent) {
       final Student student = (Student) getItem(position);
        if (view == null) {
            view = inflater.inflate(R.layout.student_report, null);
   //some code
     Button deleteButton = (Button)view.findViewById(R.id.delete_btn);
     deleteButton.setOnClickListener(new View.OnClickListener() {
         public void onClick(View view) {
     return view;
    public Object getItem(int position) {
        return students.get(position);
    public long getItemId(int position) {
        return position;
    public int getCount() {
        return students.size();
    public void setStudents(List<Student> data) {

Write Answer

©2022 concretepage.com | Privacy Policy | Contact Us