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 8824635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:40:58+00:00 2026-06-14T06:40:58+00:00

I have a ListView with items that will navigate on click. The list item

  • 0

I have a ListView with items that will navigate on click.

The list item has two text views, which have the following click handlers:

private OnClickListener playClickListener() {
        return new OnClickListener() { 
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), TestActivity.class);
                startActivity(intent);
             } 
        };
    }

Unfortunately this leads to TestActivity firing up as many times as the user clicks intbetween int loading. I tried setting the click handers to null with setOnClickListener(null). However when I navigate back to the activity the list item is then no longer clickable.

Is there a nice work around for this?

  • 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-14T06:40:59+00:00Added an answer on June 14, 2026 at 6:40 am

    You can try and use startActivityForResult().

    private static final int REQUEST_CODE_MAKE_CLICKABLE = 1;
    
    private boolean mAlreadyClicked = false;
    private OnClickListener playClickListener() {
        return new OnClickListener() { 
            @Override
            public void onClick(View v) {
                if(mAlreadyClicked) return;
                mAlreadyClicked = true;
                Intent intent = new Intent(getActivity(), TestActivity.class);
                startActivityForResult(intent, REQUEST_CODE_MAKE_CLICKABLE );
             } 
        };
    }
    
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if(requestCode == REQUEST_CODE_MAKE_CLICKABLE && resultCode == Activity.RESULT_OK) {
            mAlreadyClicked = false;
        } 
    }   
    

    and in your TestActivity you can override finish to do the following:

    @Override
    public void finish() {  
        setResult(Activity.RESULT_OK, new Intent());
        super.finish();
    }
    

    This will lead to the click being fired only once until the next activity returns and “re-enables” the click functionality.

    –OR–

    You could be boring and keep the boolean and simply “reset” it on onResume():

    private boolean mAlreadyClicked = false;
    private OnClickListener playClickListener() {
        return new OnClickListener() { 
            @Override
            public void onClick(View v) {
                if(mAlreadyClicked) return;
                mAlreadyClicked = true;
                Intent intent = new Intent(getActivity(), TestActivity.class);
                startActivity(intent, REQUEST_CODE_MAKE_CLICKABLE );
            } 
        };
    }
    
    @Override
    public void onResume() {
        super.onResume();
        mAlreadyClicked = false;
    }
    

    You should really be boring, but it’s always fun to use cross Activity callbacks. 🙂

    • 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 several items that are created dynamically, each has two
I have a list view that displays a collection of items, each item has
I have a list of items that are displayed using a ListView from a
I'm using the new ASP.Net ListView control to list database items that will be
i have a listview, my problem is that a click will register only if
how to see items that i pick on ListView ? i have this code:
I have a ListView that shows around 300 items. When something is changed and
I have a ListView that I am populating with items from an ObservableCollection .
A have a ListView that is rendered with multiple items. Now I want to
So I have a listview that is displaying correctly. When the item is turned

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.