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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:17:03+00:00 2026-06-17T21:17:03+00:00

This question has been asked a lot of times and I’ve systematically gone through

  • 0

This question has been asked a lot of times and I’ve systematically gone through each and tried to find which version of performItemClick works. Unfortunately I just can’t get any of them to work despite my onclick method being called.

I have a listview with 5 items embedded into a fragment. This fragment is controlled by a fragmentstatepageradapter and a viewpager. I’m trying to restore the saved state.

        lv.setAdapter(new SimpleAdapter(getActivity(), list,
                R.layout.list_imageview, new String[] { "answer" },
                new int[] { android.R.id.text1 }));

The simple adapter takes in a custom layout which has a textview and imageview within a layout. Initially the imageview is null and on click it is set to a tick or cross. This works when clicking the items myself just doesn’t work programatically as follows:

@Override
    public void onViewStateRestored(Bundle savedInstanceState) {
        super.onViewStateRestored(savedInstanceState);
        if (savedInstanceState != null) {
            for (int i = 0; i < 5; i++) {
                lv.performItemClick(lv.getAdapter().getView(i, null, null),
                        i, i);
                Log.e("restoring state", "" + i);
            }
        }
    }

I can confirm that onViewStateRestored is called and onItemClick is also called. I assume it’s a problem in the way I’m performing the item click. I am currently just trying to get it work; I know I haven’t yet checked which items have been clicked to selectively click them but that’s an easy boolean[] away.

I thank you for your help, and sorry for such a simple question that’s been repeated quite a few times; despite reading them I am still unable to get them to work.

  • 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-17T21:17:04+00:00Added an answer on June 17, 2026 at 9:17 pm

    I assume it’s a problem in the way I’m performing the item click.

    Right now you call performItemClick giving it a new View created by the getView method of the adapter. The problem is that if you setting the image is somehow related to the row view the onItemClick callback receives, you’ll not see any results as that view is not related(it’s “in the air”) to the row view that is actually seen on the screen(or present in the ListView). But I’m just guessing.

    Anyway, you shouldn’t tie that ImageView work to the OnItemClickListener, you should implement it at the adapter level(and call notifydataSetChanged()), especially as you’re trying to set multiple rows at once.

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

Sidebar

Related Questions

Yes, I know this question has been asked a lot of times, but I
I believe this question has been asked a lot of times, and I have
I'm aware this question has been asked a lot of times. I believe I
I know this Question has been asked several times before, and I have tried
I know this question has been asked a lot, but I want to find
I know this question has been asked a lot of times, but so far,
Alright, I guess this question has been asked a lot of times here. I
This question has been asked a lot of times in many forums. But I
This question has probably been asked a lot many times.. Yes! I am facing
This question has been asked quite a lot of time and I have tried

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.