Note that there are some explanatory texts on larger screens.

plurals
  1. POsetContentView makes my ImageView buttons unclickable?
    primarykey
    data
    text
    <p>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.</p> <p>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:</p> <pre><code> 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); </code></pre> <p>}</p> <p>and the XML for the railtrick: </p> <pre><code>&lt;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" &gt; &lt;LinearLayout android:id="@+id/title" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:orientation="horizontal" &gt; &lt;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" /&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:id="@+id/alldice" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight=".5" android:orientation="vertical" &gt; &lt;LinearLayout android:id="@+id/dicerow1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" &gt; &lt;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"/&gt; &lt;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"/&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:id="@+id/dicerow2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" &gt; &lt;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"/&gt; &lt;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"/&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:id="@+id/buttons" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:orientation="horizontal" &gt; &lt;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" /&gt; &lt;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" /&gt; &lt;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" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; &lt;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" /&gt; </code></pre> <p></p> <p>Thanks again. Love you all!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload