I uploaded my application yesterday on Google Play, and this morning I only wanted to make a layout, since some of them were overlapping buttons on smaller screens, basically I just want to move the buttons further across the screen. I thought it would be as easy as using the eclipse graphical editor ... No.
I have no idea why, but a little editing that I did to arrange the buttons on the "view_fact" layout registered the buttons with the wrong OnClick listeners, there are only two buttons on the screen and they use event listeners from different countries, and I have no idea I have why. I did not touch the event listener code, which worked fine on the old layout.
Here is my view_fact layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/viewFactTitleText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="18dp" android:text="@string/factTitleText" android:textSize="22dp" tools:context=".MainActivity" /> <ImageView android:id="@+id/randomFactImage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/viewFactTitleText" android:layout_centerHorizontal="true" android:layout_marginTop="18dp" android:contentDescription="Fact Image" android:src="@drawable/canadaflag" /> <TextView android:id="@+id/factData" android:layout_width="300dp" android:layout_height="wrap_content" android:layout_below="@+id/randomFactImage" android:layout_centerHorizontal="true" android:layout_marginTop="14dp" android:text="TextView" /> <Button android:id="@+id/anotherFactButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/backToHomeButton" android:layout_alignLeft="@+id/backToHomeButton" android:layout_alignRight="@+id/backToHomeButton" android:text="@string/anotherFactButtonText" /> <Button android:id="@+id/backToHomeButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/factData" android:layout_alignParentBottom="true" android:layout_alignRight="@+id/factData" android:text="@string/backToHomeButtonText" /> </RelativeLayout>
Listener and start code:
public class MainActivity extends Activity { private boolean debugMode = true;
Thanks.
source share