Currently for my 2.x preference screens, in every PreferenceActivity I
add the line `setContentView(R.layout.activity_preferences);` to have
a custom layout in my activities.

The activity_preferences.xml layout file looks like this:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <LinearLayout style="@style/TitleBar">
            <ImageButton style="@style/TitleBarAction"
                android:src="@drawable/ic_title_home"
                android:onClick="onHomeClick" />

            <ImageView style="@style/TitleBarSeparator" />
            <eu.vranckaert.worktime.utils.view.CustomTextView
                    style="@style/TitleBarText" android:text="@string/
lbl_preferences_title"/>
        </LinearLayout>

        <ListView android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:id="@android:id/list"/>

    </LinearLayout>

For my 3.x and up application I am building the preferences according
to the example over here: 
http://developer.android.com/reference/android/preference/PreferenceActivity.html.

In order to apply the same layout to my 3.x app, I tried was to add
the `setContentView(..)` in the 3.x PreferenceActivity.

Result on phone: this works fine on the first activity, then when
loading a fragment (with the real preferences in them) my style is not
applied

Result on tablet: crash:

        ERROR/AndroidRuntime(2208): FATAL EXCEPTION: main
        java.lang.RuntimeException: Unable to start activity
ComponentInfo{eu.vranckaert.worktime/
eu.vranckaert.worktime.activities.preferences.PreferencesICSActivity}:
java.lang.IllegalArgumentException: No view found for id 0x10202d4 for
fragment TimeRegistrationsPreferencesFragment{4101ed38 #0
id=0x10202d4}
        at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
1956)
        at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
1981)
        at android.app.ActivityThread.access$600(ActivityThread.java:
123)
        at android.app.ActivityThread
$H.handleMessage(ActivityThread.java:1147)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4424)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:784)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
551)
        at dalvik.system.NativeStart.main(Native Method)
        Caused by: java.lang.IllegalArgumentException: No view found
for id 0x10202d4 for fragment
TimeRegistrationsPreferencesFragment{4101ed38 #0 id=0x10202d4}
        at
android.app.FragmentManagerImpl.moveToState(FragmentManager.java:822)
        at
android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1032)
        at android.app.BackStackRecord.run(BackStackRecord.java:622)
        at
android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:
1382)
        at android.app.Activity.performStart(Activity.java:4474)
        at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
1929)
        ... 11 more

When I try to apply the layout file on my fragments using
`getActivity().setContentView(R.layout.activity_preferences);` the
result is:
for phone: the activity is still shown fine, when going into a
category it crashes:

        ERROR/AndroidRuntime(1320): FATAL EXCEPTION: main
        java.lang.RuntimeException: Unable to start activity
ComponentInfo{eu.vranckaert.worktime/
eu.vranckaert.worktime.activities.preferences.PreferencesICSActivity}:
java.lang.IllegalArgumentException: No view found for id 0x10202d4 for
fragment DateTimePreferencesFragment{412a0d78 #0 id=0x10202d4}
        at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
1956)
        at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
1981)
        at android.app.ActivityThread.access$600(ActivityThread.java:
123)
        at android.app.ActivityThread
$H.handleMessage(ActivityThread.java:1147)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4424)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:784)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
551)
        at dalvik.system.NativeStart.main(Native Method)
        Caused by: java.lang.IllegalArgumentException: No view found
for id 0x10202d4 for fragment
TimeRegistrationsPreferencesFragment{412a0d78 #0 id=0x10202d4}
        at
android.app.FragmentManagerImpl.moveToState(FragmentManager.java:822)
        at
android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1032)
        at android.app.BackStackRecord.run(BackStackRecord.java:622)
        at
android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:
1382)
        at android.app.Activity.performStart(Activity.java:4474)
        at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
1929)
        ... 11 more
for tablet: same crash as before...

How should I apply this layout file to my fragment activity...? Or
should I create a new layout file?

Kind regards,

Dirk Vranckaert

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to