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

  • SEARCH
  • Home
  • 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 6805703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:37:08+00:00 2026-05-26T19:37:08+00:00

I found a similar question about scrolling listview and button click but it did

  • 0

I found a similar question about scrolling listview and button click but it did not help me. My issue is:

I have a listview with custom rows. I have two different states of listview; the switch between the states is a button at the bottom of the screen. The second state has delete buttons in every row. When I click on delete button in a specific row, that row is removed from database and listview is updated. Everything works great except I need to click the delete button twice in order for it to work. Below is my code for handling the clicks. flag==1 is the second state of the listview.

public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    View main = parent.getChildAt(position);
    TextView delete = (TextView)main.findViewById(R.id.delete_button);

    if(flag==0){
        switchToItemsView(id);
    }
    if(flag==1){
        delete.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        mDbHelper.deleteList(id);
                        updateListView();
                    }});
    }
}

I tried to set parent view’s focusableInTouchMode attribute to false as suggested in another post but it did not help.

If you can help me solve this I will be grateful,

Thank you in advance.

  • 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-05-26T19:37:09+00:00Added an answer on May 26, 2026 at 7:37 pm

    After spending hours I figured out how to do it:

    I moved my click listener from my main activity class to my custom ListAdapter class and modified it a little like below;

    deleteButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            int rowid = Integer.parseInt(rowIds.get(position));
            mDb.deleteList(rowid);
            lists.remove(position);
            notifyDataSetChanged();
        }
    });
    

    Now it works great. When I click delete button it removes the list both from the ArrayList (the one used in ListAdapter) and from database.

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

Sidebar

Related Questions

I can't resolve this issue, I found a similar question here but: setting the
I found a similar question about getting just the rotation, but as I understand
So, I found a similar question here , but the answers are more about
I've found a similar question on stack overflow, but it didn't really answer the
I've found a similar question here , but I'm looking for more general solutions.
I've looked around on stackoverflow for a similar question, but haven't found exactly what
I found this on Google, click here , which someone asked a similar question,
I found this question but it was only similar and, more importantly, dated by
I found a couple questions similar to this, but not specifically for .NET projects,
There is a similar question about Windows, but it won't work for Unix based

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.