Moving adMob ads to the bottom of Relative Layout crashes the app - android

I'm implementing adMob ads to my app and I have a small problem with it. When I add the AdMob ads to my app and they're automatically positioned on the top of the layout it all works good. But when I try to move the ad down to the bottom of the relative layout the app crashes.
Logcat:
08-14 13:57:53.126: E/AndroidRuntime(4141): FATAL EXCEPTION: main
08-14 13:57:53.126: E/AndroidRuntime(4141): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.whizzappseasyvoicenotepad/com.whizzappseasyvoicenotepad.TabLayout}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.whizzappseasyvoicenotepad/com.whizzappseasyvoicenotepad.MainActivity}: java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.Chronometer
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.os.Handler.dispatchMessage(Handler.java:99)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.os.Looper.loop(Looper.java:137)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-14 13:57:53.126: E/AndroidRuntime(4141): at java.lang.reflect.Method.invokeNative(Native Method)
08-14 13:57:53.126: E/AndroidRuntime(4141): at java.lang.reflect.Method.invoke(Method.java:525)
08-14 13:57:53.126: E/AndroidRuntime(4141): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-14 13:57:53.126: E/AndroidRuntime(4141): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-14 13:57:53.126: E/AndroidRuntime(4141): at dalvik.system.NativeStart.main(Native Method)
08-14 13:57:53.126: E/AndroidRuntime(4141): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.whizzappseasyvoicenotepad/com.whizzappseasyvoicenotepad.MainActivity}: java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.Chronometer
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.app.ActivityThread.startActivityNow(ActivityThread.java:2054)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:749)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.widget.TabHost.setCurrentTab(TabHost.java:413)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.widget.TabHost.addTab(TabHost.java:240)
08-14 13:57:53.126: E/AndroidRuntime(4141): at com.whizzappseasyvoicenotepad.TabLayout.onCreate(TabLayout.java:33)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.app.Activity.performCreate(Activity.java:5133)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
08-14 13:57:53.126: E/AndroidRuntime(4141): ... 11 more
08-14 13:57:53.126: E/AndroidRuntime(4141): Caused by: java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.Chronometer
08-14 13:57:53.126: E/AndroidRuntime(4141): at com.whizzappseasyvoicenotepad.MainActivity.onCreate(MainActivity.java:71)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.app.Activity.performCreate(Activity.java:5133)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-14 13:57:53.126: E/AndroidRuntime(4141): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
08-14 13:57:53.126: E/AndroidRuntime(4141): ... 21 more
I tested it, and everytime I implement ads, they work until I move them down to the bottom of the relative layout. What could be the problem? I can see from the logcat that there's a problem with ToggleButton so I even tried moving the togglebutton around the layout but it doesn't fix anything.
XML:
<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"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" xmlns:app="http://schemas.android.com/apk/lib/com.google.ads">
<Chronometer
android:id="#+id/timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/adView"
android:layout_centerHorizontal="true"
android:text="Chronometer" />
<ImageButton
android:id="#+id/recButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/timer"
android:layout_centerHorizontal="true"
android:background="#null"
android:onClick="recordBtnClick"
android:src="#drawable/record_btn" />
<ToggleButton
android:id="#+id/tBtn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textOff="Touch to record"
android:textOn="Touch to record" />
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR, 3F40A7AF85746C87"
app:adSize="BANNER"
app:adUnitId="a1520b668ee78d8" >
</com.google.ads.AdView>

You have a class cast exception at line 71 of your code. If line 71 of your code is
chTimer = (Chronometer)findViewById(R.id.timer);
as you indicated in your response to Arshad then you have a confused build environment where the generated resource ids are not what you think they are.
Do a clean build so that the resource ids are regenerated.

Please check your MainActivity.java file on Line No. 71. You are passing the Chronometer id into the ImageButton. That's why you are getting a Class cast exception

Related

android crash on internet connection turn off

I am new to android, as my study project I made an application. Which is syncing data from webservice and fetching in my application.
Everything working fine.
But in this scenario
Launch the application
Check for internet connection
Get content from server
Fetch data in application
5. When we turn off Mobile Data / WiFi , then press any button in application suddenly application crashes.
There is any way to handle this issue ?
Thanks in advance
Error message
08-14 21:28:57.670: E/AndroidRuntime(7466): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.tvc/com.myapp.tvc.SingleActivity}: java.lang.NullPointerException
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.access$600(ActivityThread.java:140)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.os.Handler.dispatchMessage(Handler.java:99)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.os.Looper.loop(Looper.java:137)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.main(ActivityThread.java:4895)
08-14 21:28:57.670: E/AndroidRuntime(7466): at java.lang.reflect.Method.invokeNative(Native Method)
08-14 21:28:57.670: E/AndroidRuntime(7466): at java.lang.reflect.Method.invoke(Method.java:511)
08-14 21:28:57.670: E/AndroidRuntime(7466): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
08-14 21:28:57.670: E/AndroidRuntime(7466): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
08-14 21:28:57.670: E/AndroidRuntime(7466): at dalvik.system.NativeStart.main(Native Method)
08-14 21:28:57.670: E/AndroidRuntime(7466): Caused by: java.lang.NullPointerException
08-14 21:28:57.670: E/AndroidRuntime(7466): at com.myapp.tvc.SingleActivity.onCreate(SingleActivity.java:76)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.Activity.performCreate(Activity.java:5163)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
08-14 21:28:57.670: E/AndroidRuntime(7466): ... 11 more
whatever is at line 76 of SingleActivity is null, since you did not provide code the best we can say is find out what and why is null at that line
My most common error is something is nulll. Maybe the handler is defined inline and your using a variable that is null
Based on what you're describing and without seeing your code it sounds like you're just trying to connect to the internet when no internet connection exists. To fix this problem you can create a network checker/listener that can check network availability before you try to do anything that requires an internet connection. If no connection is available you just don't run the task that gets stuff from the server. A more involved set up could be designed using a BroadcastReceiver (e.g. so you know when connectivity becomes available again) but try this for now and see if that's your issue.

Selecting an item in ListFragment list programmatically

I've made my Android app tablet optimized and I followed the tutorial here:
Everything is great, but I am trying to select an item (say, the 1st item) with a button in the ActionBar.
I tried this answer to use performItemClick but on I've got error reports of java.lang.IllegalStateException
in android.support.v4.app.ListFragment.ensureList, java.lang.IllegalStateException: Content view not yet created, and java.lang.NullPointerException
in android.content.ComponentName.<init>
I've tried checking if the ListView is null and still get the error reports on the Play Store. How do I properly select an item in my list programmatically?
Update to add logcat and the code is virtually identical to the tutorials in the links:
Logcat A:
java.lang.IllegalStateException: Content view not yet created
at android.support.v4.app.ListFragment.ensureList(ListFragment.java:328)
at android.support.v4.app.ListFragment.getListView(ListFragment.java:222)
at com.ccwilcox.meteorshower.MeteorList.showMeteorDetails(MeteorList.java:69)
at com.ccwilcox.meteorshower.MeteorList.onListItemClick(MeteorList.java:62)
at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
at android.widget.AdapterView.performItemClick(AdapterView.java:298)
at android.widget.AbsListView.performItemClick(AbsListView.java:1280)
at com.ccwilcox.meteorshower.MainActivity.viewUpcomingEvent(MainActivity.java:648)
at com.ccwilcox.meteorshower.MainActivity.onOptionsItemSelected(MainActivity.java:534)
at android.app.Activity.onMenuItemSelected(Activity.java:2606)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:361)
at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1045)
at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
at com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:592)
at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:149)
at android.view.View.performClick(View.java:4222)
at android.view.View$PerformClick.run(View.java:17273)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4895)
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:994)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
at dalvik.system.NativeStart.main(Native Method)
Logcat B:
java.lang.NullPointerException
at android.content.ComponentName.<init>(ComponentName.java:75)
at android.content.Intent.<init>(Intent.java:2874)
at com.ccwilcox.meteorshower.MeteorList.showMeteorDetails(MeteorList.java:86)
at com.ccwilcox.meteorshower.MeteorList.onListItemClick(MeteorList.java:62)
at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
at android.widget.AdapterView.performItemClick(AdapterView.java:284)
at android.widget.ListView.performItemClick(ListView.java:3701)
at com.ccwilcox.meteorshower.MainActivity.viewUpcomingEvent(MainActivity.java:648)
at com.ccwilcox.meteorshower.MainActivity.onOptionsItemSelected(MainActivity.java:534)
at android.app.Activity.onMenuItemSelected(Activity.java:2205)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:361)
at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:779)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:861)
at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
at android.view.View$PerformClick.run(View.java:9152)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Update 2
And here is the code that is causing the problem:
if (mListFragment.listView != null) {
mListFragment.listView.performItemClick(mListFragment.listView.getAdapter().getView(position, null, null), position, mListFragment.listView.getAdapter().getItemId(position));
}

Error at runtime - what to do?

What does this error mean? I'm having this error at runtime. The app crashes when I try to launch. I am new at Android programming.
I have tried to look through the code and I couldn't find it. I would appreciate your help.
02-07 14:32:57.967: E/Trace(943): error opening trace file: No such file or directory (2)
02-07 14:32:58.386: E/AndroidRuntime(943): FATAL EXCEPTION: main
02-07 14:32:58.386: E/AndroidRuntime(943): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.quiz/com.example.quiz.Splash}: java.lang.ClassNotFoundException: Didn't find class "com.example.quiz.Splash" on path: /data/app/com.example.quiz-2.apk
02-07 14:32:58.386: E/AndroidRuntime(943): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
02-07 14:32:58.386: E/AndroidRuntime(943): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-07 14:32:58.386: E/AndroidRuntime(943): at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-07 14:32:58.386: E/AndroidRuntime(943): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-07 14:32:58.386: E/AndroidRuntime(943): at android.os.Handler.dispatchMessage(Handler.java:99)
02-07 14:32:58.386: E/AndroidRuntime(943): at android.os.Looper.loop(Looper.java:137)
02-07 14:32:58.386: E/AndroidRuntime(943): at android.app.ActivityThread.main(ActivityThread.java:5039)
02-07 14:32:58.386: E/AndroidRuntime(943): at java.lang.reflect.Method.invokeNative(Native Method)
02-07 14:32:58.386: E/AndroidRuntime(943): at java.lang.reflect.Method.invoke(Method.java:511)
02-07 14:32:58.386: E/AndroidRuntime(943): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-07 14:32:58.386: E/AndroidRuntime(943): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-07 14:32:58.386: E/AndroidRuntime(943): at dalvik.system.NativeStart.main(Native Method)
02-07 14:32:58.386: E/AndroidRuntime(943): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.quiz.Splash" on path: /data/app/com.example.quiz-2.apk
02-07 14:32:58.386: E/AndroidRuntime(943): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
02-07 14:32:58.386: E/AndroidRuntime(943): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
02-07 14:32:58.386: E/AndroidRuntime(943): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
02-07 14:32:58.386: E/AndroidRuntime(943): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
02-07 14:32:58.386: E/AndroidRuntime(943): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
02-07 14:32:58.386: E/AndroidRuntime(943): ... 11 more
First of all, check if your source is where it is mentioned in the error log.
If it is, check if you've made any typing mistakes
If it still isn't working, it would be easier (In my opinion) to create a new project and rename what is missing (I've done this several times already and it has always worked) Of course, make sure you copy all of your code
It looks like you've missed out your Splash activity in your manifest.
<activity android:name=".Splash"/>
See if that line appears in your manifest, if not you should add it.

Maps not working

.I have simple map applicaiton.First simply my map is working.then i allow to develop my application i got Force close.When i run my application i got following error:
08-14 20:57:26.855: E/AndroidRuntime(207): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mapss/com.example.mapss.MainActivity}: java.lang.SecurityException: Requires ACCESS_FINE_LOCATION permission
08-14 20:57:26.855: E/AndroidRuntime(207): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.os.Handler.dispatchMessage(Handler.java:99)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.os.Looper.loop(Looper.java:123)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.app.ActivityThread.main(ActivityThread.java:4203)
08-14 20:57:26.855: E/AndroidRuntime(207): at java.lang.reflect.Method.invokeNative(Native Method)
08-14 20:57:26.855: E/AndroidRuntime(207): at java.lang.reflect.Method.invoke(Method.java:521)
08-14 20:57:26.855: E/AndroidRuntime(207): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
08-14 20:57:26.855: E/AndroidRuntime(207): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
08-14 20:57:26.855: E/AndroidRuntime(207): at dalvik.system.NativeStart.main(Native Method)
08-14 20:57:26.855: E/AndroidRuntime(207): Caused by: java.lang.SecurityException: Requires ACCESS_FINE_LOCATION permission
08-14 20:57:26.855: E/AndroidRuntime(207): at android.os.Parcel.readException(Parcel.java:1218)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.os.Parcel.readException(Parcel.java:1206)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.location.ILocationManager$Stub$Proxy.getLastKnownLocation(ILocationManager.java:776)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.location.LocationManager.getLastKnownLocation(LocationManager.java:945)
08-14 20:57:26.855: E/AndroidRuntime(207): at com.example.mapss.MainActivity.onCreate(MainActivity.java:36)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
08-14 20:57:26.855: E/AndroidRuntime(207): ... 11 more
add this line to your AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
When using Maps or other types of services, you need to make sure that you add appropriate permissions to your manifest, in this case:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
You will need to add permissions when you use things like the internet and calling.

Customize Android PreferenceFragment not working

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?

Categories

Resources