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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:02:48+00:00 2026-05-26T21:02:48+00:00

Having some trouble figuring out why my ImageView buttons stop working after I change

  • 0

Having some trouble figuring out why my ImageView buttons stop working after I change the displayed layout in my app. Please tell me if you see anything wrong with this code… The buttons are not clickable after changing setContentView is called even though it is setting the layout to the same one that is originally set in OnCreate. Basically I want to be able to reset the view to an known state whenever I want by calling this function.

Thanks for any ideas! Here is the code that breaks the buttons, really only the line that calls setContentView breaks the buttons, but here is the rest of the function as well:

    public void defaultrailview(){
      setContentView(R.layout.railtrick);
      ImageView jumpsbutton = (ImageView) findViewById(R.id.jumpsbutton);
      ImageView settingsbutton = (ImageView) findViewById(R.id.settingsbutton);
      jumpsbutton.setClickable(true);
      settingsbutton.setClickable(true);    
      ImageView ghost1 = (ImageView)findViewById(R.id.rt1);
      ghost1.setAlpha(51);
      ImageView ghost2 = (ImageView)findViewById(R.id.rt2);
      ghost2.setAlpha(51);
      ImageView ghost3 = (ImageView)findViewById(R.id.rt3);
      ghost3.setAlpha(51);
      ImageView ghost4 = (ImageView)findViewById(R.id.rt4);
      ghost4.setAlpha(51);
      ImageView railtext = (ImageView)findViewById(R.id.railstext);
      railtext.setAlpha(127);
      ImageView shaketoroll = (ImageView)findViewById(R.id.ShakeToRoll);
      shaketoroll.setVisibility(4);

}

and the XML for the railtrick:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/title"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/railstext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:paddingLeft="20dp"
            android:src="@drawable/railstext" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/alldice"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight=".5"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/dicerow1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1" >

            <ImageView
                android:id="@+id/rt1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:layout_weight="1"
                android:adjustViewBounds="true"
                android:paddingLeft="10dp"
                android:src="@drawable/diceghost"/>

            <ImageView
                android:id="@+id/rt2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:layout_weight="1"
                android:adjustViewBounds="true"
                android:paddingRight="10dp"
                android:src="@drawable/diceghost"/>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/dicerow2"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1" >

            <ImageView
                android:id="@+id/rt3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="top"
                android:layout_marginTop="5dp"
                android:layout_weight="1"
                android:adjustViewBounds="true"
                android:paddingLeft="10dp"
                android:src="@drawable/diceghost"/>

            <ImageView
                android:id="@+id/rt4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="top"
                android:layout_marginTop="5dp"
                android:layout_weight="1"
                android:adjustViewBounds="true"
                android:paddingRight="10dp"
                android:src="@drawable/diceghost"/>
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/buttons"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/jumpsbutton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_weight="1"
            android:adjustViewBounds="true"
            android:clickable="true"
            android:paddingLeft="20dp"
            android:src="@drawable/jumpsbuttonpassive" />

        <ImageView
            android:id="@+id/railsbutton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_weight="1"
            android:adjustViewBounds="true"
            android:clickable="true"
            android:paddingLeft="5dp"
            android:paddingRight="5dp"
            android:src="@drawable/railsbuttonactive" />

        <ImageView
            android:id="@+id/settingsbutton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_weight="1"
            android:adjustViewBounds="true"
            android:clickable="true"
            android:paddingRight="20dp"
            android:src="@drawable/settingsbuttonpassive" />
    </LinearLayout>
</LinearLayout>

<ImageView
    android:id="@+id/ShakeToRoll"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:adjustViewBounds="true"
    android:padding="30dp"
    android:src="@drawable/shaketoroll" />

Thanks again. Love you all!

  • 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-26T21:02:49+00:00Added an answer on May 26, 2026 at 9:02 pm

    When passing the same value into setContentView, you are still requesting for that resource to be inflated – meaning all new objects.

    You need to reassign your onClickListeners because your old buttons are no longer on the screen.

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

Sidebar

Related Questions

I am working on a REST based API, and having some trouble figuring out
I'm having some trouble figuring out to call methods that I have in other
I'm having some trouble figuring out how to make a reference to a subroutine
I'm having some trouble figuring this out. I have an unordered list menu that
I'm having some conceptual trouble on figuring out how to best implement this... I
I'm having some trouble figuring out the best/Djangoic way to do this. I'm creating
I'm having some trouble figuring this out. I want to make it so I
I having some trouble figuring this problem out where I have one button which
i'm having some trouble figuring out how to save unicode into a file in
I'm having some trouble figuring out how to make the page load architecture of

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.