[android-developers] Preferences button to return to main activity
I have a preferences screen that works as expected, with one exception.
I added a button preference that when pressed should take the user back to the main activity screen.
The button appears; it even changes colored when tapped, however, no action takes place.
Here are the files and code that I think show what I've done.
If you have any insight on how this should work, I would appreciate it.
returntogame.xml (defines the button)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:weightSum="10"
android:baselineAligned="false" android:orientation="horizontal">
<Button
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:weightSum="10"
android:baselineAligned="false" android:orientation="horizontal">
<Button
android:text="Return to game" android:layout_width="fill_parent"
android:layout_weight="5" android:layout_height="wrap_content"
android:id="@+id/returnToGame" android:layout_gravity="left">
</Button>
</LinearLayout>
android:layout_weight="5" android:layout_height="wrap_content"
android:id="@+id/returnToGame" android:layout_gravity="left">
</Button>
</LinearLayout>
~~~~~~~~~~~~~~~~~~~~~~~~~~~
preferences.xml (includes the button at the top of the preferences screen)
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<Preference android:layout="@layout/returntogame" android:key="returnToGame">
<intent android:action="android.intent.action.MAIN"/>
</Preference>
<Preference android:layout="@layout/returntogame" android:key="returnToGame">
<intent android:action="android.intent.action.MAIN"/>
</Preference>
...
</PreferenceScreen>
~~~~~~~~~~~~~~~~~~~~~~~~~~~
manifest.xml
<activity
android:name="PrefsActivity"
android:label="Preferences"
android:enabled="true" >
<intent-filter>
<category android:name="android.intent.category.PREFERENCE" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
android:name="PrefsActivity"
android:label="Preferences"
android:enabled="true" >
<intent-filter>
<category android:name="android.intent.category.PREFERENCE" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home