Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7848475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:13:04+00:00 2026-06-02T18:13:04+00:00

I am making a ListView with TextView and 1 delete button for each row.

  • 0

I am making a ListView with TextView and 1 delete button for each row.

To populate the list I am using my custom adaptor (extends base adapter) and sqlite db to map into list.

My requirement is onclick of delete button in a row that record should be deleted and list should refresh.

I am able to delete record from db but my list is not refreshing until I rotate the device or assign a new instance of my adapter from activity.

I have tried following answer
but didn’t work in my case. the difference between this answer and my case is I am using baseAdapter and he is using cursorAdapter.

 public class BookmarksPDFAdapter extends BaseAdapter { 

            public View getView(int position, View convertView, ViewGroup parent) {
            openDatabase();




            btnDelete.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {

                    deleteBookmark(getLocation(v));//getlocation(View) method returns which delete button clicked
                    notifyDataSetChanged();

                }
            });
        }
        closeDatabase();
        return convertView;
    }

my activity looks like

public class BookmarkActivity extends Activity {


@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub

    super.onCreate(savedInstanceState);
    setContentView(R.layout.bookmarks);
    btnEdit = (Button) findViewById(R.id.edit_bookmarks);
    btnAdd = (Button) findViewById(R.id.add_bookmarks);

    list = (ListView) findViewById(android.R.id.list);

    adapter = new BookmarksPDFAdapter(this);

    list.setAdapter(adapter);
}

bookmark.xml

<LinearLayout 
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="10.0" 
android:paddingTop="5dp">

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"

    android:padding="3dip"
    android:layout_alignParentLeft="true"
    android:weightSum="1.0" 
    android:layout_marginRight="5dip">

    <ImageView
        android:id="@+id/iconShow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/delete_icon"
        android:visibility="invisible" 
        android:layout_weight="1.0"/>
</LinearLayout>

<TextView
    android:id="@+id/bookmark_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="6dp"
    android:layout_weight="7.0"
    android:gravity="center_horizontal|center_horizontal"
    android:lines="1"
    android:text="@+id/TextView01"
    android:textSize="24dp" />

<Button
    android:id="@+id/btnDelete"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="right"
    android:layout_weight="2.0"
    android:text="@string/btn_txt_delete"
    android:visibility="invisible" >
</Button>

listitem.xml

<LinearLayout 
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="10.0" 
android:paddingTop="5dp">

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"

    android:padding="3dip"
    android:layout_alignParentLeft="true"
    android:weightSum="1.0" 
    android:layout_marginRight="5dip">

    <ImageView
        android:id="@+id/iconShow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/delete_icon"
        android:visibility="invisible" 
        android:layout_weight="1.0"/>
</LinearLayout>

<TextView
    android:id="@+id/bookmark_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="6dp"
    android:layout_weight="7.0"
    android:gravity="center_horizontal|center_horizontal"
    android:lines="1"
    android:text="@+id/TextView01"
    android:textSize="24dp" />

<Button
    android:id="@+id/btnDelete"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="right"
    android:layout_weight="2.0"
    android:text="@string/btn_txt_delete"
    android:visibility="invisible" >
</Button>

deleteBookmark method

void deleteBookmark(int wantedChild) {

    String bookmarkItem = getBookmarkItemText(wantedChild, true);
    datasource.open();
    int check = datasource.deleteBookmark(bookmarkItem);
    if (check == 1) {

        btnDelete = (Button) (viewList.get(wantedChild)
                .findViewById(R.id.btnDelete));

        btnDelete.setText(R.string.btn_txt_deleted);
        btnDelete.setEnabled(false);
    }

    datasource.close();
}

Here I am deleting record from my database and changing text of delete button from delete to deleted

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:13:06+00:00Added an answer on June 2, 2026 at 6:13 pm
    adapter.notifyDataSetChanged();
    

    You can call the above method to refresh list view any time. In your case call it after you delete a record from database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listview with custom rows and that extends SimpleAdapter. Each row consist
I've a ListView where every element in the list contains a TextView and two
I'm currently having an issue with using custom ListView adapters with the Holo.Light theme.
I am making listview which data fill by json parsing,I am using Customadapter in
I created a ListView with a custom layout for each view. I have several
I have a ListView that is fed by an SQLiteDB. On each row returned,
I have a ListView where each row has a fixed height. Every row contains,
I have a ListView that contains button on each item. I want that the
I am making a custom listview, in that data is dynamically changing after sometime.
I'm making a WinForms app with a ListView set to detail so that several

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.