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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:45:06+00:00 2026-05-14T01:45:06+00:00

In my activity I respond to an onClick() by replacing the current view with

  • 0

In my activity I respond to an onClick() by replacing the current view with a new one (setContentView()). For some reason when I do this and then go back to the original view later the button I originally pressed still looks like it is pressed.

If you ‘refresh’ it somehow (e.g. scroll over it with the trackball) then it reverts to the unpressed state. It’s as if the button doesn’t get the ‘touch-up’ event.

The weird thing is: This only happens on my T-Mobile Pulse (android 1.5). It doesn’t happen on the emulator.

I’ve tried calling invalidate()/postInvalidate() on the view when I show it but it doesn’t have any effect.

  • 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-14T01:45:07+00:00Added an answer on May 14, 2026 at 1:45 am

    My guess is that your “touch-up” event will go to your new content view.

    You can either:

    • Not call setContentView() at all in onClick(), using other means of achieving your UI aims (multiple activities, ViewFlipper, etc.).
    • Not call setContentView() immediately in onClick(), but instead post() a Runnable that will call setContentView(). That should put the content view replacement in the event queue after the “touch-up” event.

    Personally, I am not a big fan of activities constantly calling setContentView(), as I worry about memory leaks and overly-plump activities making state and memory management more difficult. For example, let’s say you call setContentView() for your original layout (A), then call setContentView() for your new layout (B), then the user rotates the screen. Android’s default onSaveInstanceState() will help you with B — hanging onto EditText contents and the like — but for A, you’re on your own.

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

Sidebar

Related Questions

I hope this is any easy one. I have a view that I want
depending on some settings I decide which activity to start. This decision is done
i am using camera resource in my activity some time activity does not respond
This activity is used for login. It post the username and password to a
My application has one activity which starts two services but does not bind them.
I have some code like this: respond_to do |format| format.html { @all_activities = current_user.recent_activities(@size_per_page,params[:start],nil)
I have an Activity that generates some MotionEvent s (via MotionEvent.obtain() ). I'd like
please can you explain me why this code @activities = Activity.joins(:events, :infos).where(infos.language_id = ?
I would like to create some text on the stage that does not respond
I am trying to respond to a result from an activity using startActivityForResult. I

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.