I'm using solution of Scroll webview horizontally inside a ViewPager
it's looks very useful, I was reference ExtendedWebView in xml,
<ExtendedWebView
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
instance ExtendedWebView in .class,
LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layout = mInflater.inflate(R.layout.lay1, null);
ExtendedWebView webView = (ExtendedWebView)layout.findViewById(R.id.webview);
but i got 'Error inflating class ExtendedWebView', so could anybody to help me to give me some ideas, thanks for your time and experience!
heres are entire stack trace,
12-27 22:14:44.263: E/AndroidRuntime(10824): FATAL EXCEPTION: main
12-27 22:14:44.263: E/AndroidRuntime(10824): android.view.InflateException: Binary XML file line #7: Error inflating class com.vv_package_name.ExtendedWebView
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
12-27 22:14:44.263: E/AndroidRuntime(10824): at com.vv_package_name.vv_main$ExtendedPagerAdapter.instantiateItem(vv_main.java:135)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.support.v4.view.PagerAdapter.instantiateItem(PagerAdapter.java:110)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:801)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.support.v4.view.ViewPager.populate(ViewPager.java:930)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.support.v4.view.ViewPager.populate(ViewPager.java:881)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1366)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.View.measure(View.java:8226)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.widget.LinearLayout.measureVertical(LinearLayout.java:526)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.View.measure(View.java:8226)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.View.measure(View.java:8226)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.widget.LinearLayout.measureVertical(LinearLayout.java:526)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.View.measure(View.java:8226)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.View.measure(View.java:8226)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.ViewRoot.performTraversals(ViewRoot.java:801)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.os.Looper.loop(Looper.java:123)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-27 22:14:44.263: E/AndroidRuntime(10824): at java.lang.reflect.Method.invokeNative(Native Method)
12-27 22:14:44.263: E/AndroidRuntime(10824): at java.lang.reflect.Method.invoke(Method.java:521)
12-27 22:14:44.263: E/AndroidRuntime(10824): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
12-27 22:14:44.263: E/AndroidRuntime(10824): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-27 22:14:44.263: E/AndroidRuntime(10824): at dalvik.system.NativeStart.main(Native Method)
12-27 22:14:44.263: E/AndroidRuntime(10824): Caused by: java.lang.ClassNotFoundException: com.vv_package_name.ExtendedWebView in loader dalvik.system.PathClassLoader[/data/app/com.vv_package_name-2.apk]
12-27 22:14:44.263: E/AndroidRuntime(10824): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
12-27 22:14:44.263: E/AndroidRuntime(10824): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
12-27 22:14:44.263: E/AndroidRuntime(10824): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
12-27 22:14:44.263: E/AndroidRuntime(10824): ... 33 more
if using WebView instead of ExtendedWebView, my code is working fine :)
You need to provide a full reference to the class, including the package.
For instance,
<org.example.myapp.ExtendedWebView
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
sorry i'm a noob, it's my problem, i put these extend webview code in main Activity class in one .class file...it should be save with a standalone .class file...:)
public class ExtendedWebView extends WebView {
Solved for me by using this in my XML:
<view
class="com.example.MainActivity$MyWebView"
android:id="#+id/web_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Related
My reports provide me this error but I can't understand how is it possible?
java.lang.RuntimeException: Unable to start activity ComponentInfo{net.aviascanner.aviascanner/net.aviascanner.aviascanner.ui.activities.GetCitiesActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2753)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3905)
at android.app.ActivityThread.access$2600(ActivityThread.java:129)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2121)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4717)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:853)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:262)
at net.aviascanner.aviascanner.ui.activities.GetCitiesActivity.onCreate(GetCitiesActivity.java:115)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2717)
... 12 more
Caused by: java.lang.reflect.InvocationTargetException
at android.widget.EditText.<init>(EditText.java:51)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
... 25 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/selector_edittext.xml from drawable resource ID #0x7f0200c4
at android.content.res.Resources.loadDrawable(Resources.java:1725)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1901)
at android.widget.TextView.<init>(TextView.java:440)
at android.widget.EditText.<init>(EditText.java:55)
... 29 more
Caused by: java.lang.NullPointerException
at android.graphics.drawable.DrawableContainer$DrawableContainerState.addChild(DrawableContainer.java:349)
at android.graphics.drawable.StateListDrawable$StateListState.addStateSet(StateListDrawable.java:265)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:796)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:737)
at android.content.res.Resources.loadDrawable(Resources.java:1722)
... 33 more
android.view.InflateException: Binary XML file line #11: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:853)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:262)
at net.aviascanner.aviascanner.ui.activities.GetCitiesActivity.onCreate(GetCitiesActivity.java:115)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2717)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3905)
at android.app.ActivityThread.access$2600(ActivityThread.java:129)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2121)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4717)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at android.widget.EditText.<init>(EditText.java:51)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
... 25 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/selector_edittext.xml from drawable resource ID #0x7f0200c4
at android.content.res.Resources.loadDrawable(Resources.java:1725)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1901)
at android.widget.TextView.<init>(TextView.java:440)
at android.widget.EditText.<init>(EditText.java:55)
... 29 more
Caused by: java.lang.NullPointerException
at android.graphics.drawable.DrawableContainer$DrawableContainerState.addChild(DrawableContainer.java:349)
at android.graphics.drawable.StateListDrawable$StateListState.addStateSet(StateListDrawable.java:265)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:796)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:737)
at android.content.res.Resources.loadDrawable(Resources.java:1722)
... 33 more
java.lang.reflect.InvocationTargetException
at android.widget.EditText.<init>(EditText.java:51)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:853)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:262)
at net.aviascanner.aviascanner.ui.activities.GetCitiesActivity.onCreate(GetCitiesActivity.java:115)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2717)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3905)
at android.app.ActivityThread.access$2600(ActivityThread.java:129)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2121)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4717)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/selector_edittext.xml from drawable resource ID #0x7f0200c4
at android.content.res.Resources.loadDrawable(Resources.java:1725)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1901)
at android.widget.TextView.<init>(TextView.java:440)
at android.widget.EditText.<init>(EditText.java:55)
... 29 more
Caused by: java.lang.NullPointerException
at android.graphics.drawable.DrawableContainer$DrawableContainerState.addChild(DrawableContainer.java:349)
at android.graphics.drawable.StateListDrawable$StateListState.addStateSet(StateListDrawable.java:265)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:796)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:737)
at android.content.res.Resources.loadDrawable(Resources.java:1722)
... 33 more
android.content.res.Resources$NotFoundException: File res/drawable/selector_edittext.xml from drawable resource ID #0x7f0200c4
at android.content.res.Resources.loadDrawable(Resources.java:1725)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1901)
at android.widget.TextView.<init>(TextView.java:440)
at android.widget.EditText.<init>(EditText.java:55)
at android.widget.EditText.<init>(EditText.java:51)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:853)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:262)
at net.aviascanner.aviascanner.ui.activities.GetCitiesActivity.onCreate(GetCitiesActivity.java:115)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2717)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3905)
at android.app.ActivityThread.access$2600(ActivityThread.java:129)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2121)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4717)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.graphics.drawable.DrawableContainer$DrawableContainerState.addChild(DrawableContainer.java:349)
at android.graphics.drawable.StateListDrawable$StateListState.addStateSet(StateListDrawable.java:265)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:796)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:737)
at android.content.res.Resources.loadDrawable(Resources.java:1722)
... 33 more
java.lang.NullPointerException
at android.graphics.drawable.DrawableContainer$DrawableContainerState.addChild(DrawableContainer.java:349)
at android.graphics.drawable.StateListDrawable$StateListState.addStateSet(StateListDrawable.java:265)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:796)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:737)
at android.content.res.Resources.loadDrawable(Resources.java:1722)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1901)
at android.widget.TextView.<init>(TextView.java:440)
at android.widget.EditText.<init>(EditText.java:55)
at android.widget.EditText.<init>(EditText.java:51)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:853)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:262)
at net.aviascanner.aviascanner.ui.activities.GetCitiesActivity.onCreate(GetCitiesActivity.java:115)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2717)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3905)
at android.app.ActivityThread.access$2600(ActivityThread.java:129)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2121)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4717)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
I have found this error in my application also. In my application I solved my problem by making the copies of the drawables in all the folders of the drawables i.e. drawable-ldpi, drawable-mdpi, drawable-hdpi, drawable-xhdpi. This works correctly in my application. Hope this will solve your problem if u have not kept the drawables into all the provided drawable folders.
I am trying to insert images from the drawable folder to ImageView on custom listview. But when i set the images on satisfying the condition its giving the following warnings from getView.
12-27 11:56:56.356: DEBUG/skia(341): ---- read threw an exception
12-27 11:56:56.366: WARN/System.err(341): java.io.IOException: Is a directory
12-27 11:56:56.366: WARN/System.err(341): at org.apache.harmony.luni.platform.OSFileSystem.read(Native Method)
12-27 11:56:56.366: WARN/System.err(341): at dalvik.system.BlockGuard$WrappedFileSystem.read(BlockGuard.java:165)
12-27 11:56:56.366: WARN/System.err(341): at java.io.FileInputStream.read(FileInputStream.java:290)
12-27 11:56:56.366: WARN/System.err(341): at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:166)
12-27 11:56:56.366: WARN/System.err(341): at java.io.BufferedInputStream.read(BufferedInputStream.java:324)
12-27 11:56:56.366: WARN/System.err(341): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
12-27 11:56:56.366: WARN/System.err(341): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:470)
12-27 11:56:56.378: WARN/System.err(341): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:284)
12-27 11:56:56.378: WARN/System.err(341): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:309)
12-27 11:56:56.378: WARN/System.err(341): at android.graphics.drawable.Drawable.createFromPath(Drawable.java:800)
12-27 11:56:56.378: WARN/System.err(341): at android.widget.ImageView.resolveUri(ImageView.java:528)
12-27 11:56:56.378: WARN/System.err(341): at android.widget.ImageView.setImageURI(ImageView.java:305)
12-27 11:56:56.378: WARN/System.err(341): at android.widget.SimpleAdapter.setViewImage(SimpleAdapter.java:264)
12-27 11:56:56.378: WARN/System.err(341): at android.widget.SimpleAdapter.bindView(SimpleAdapter.java:192)
12-27 11:56:56.378: WARN/System.err(341): at android.widget.SimpleAdapter.createViewFromResource(SimpleAdapter.java:126)
12-27 11:56:56.378: WARN/System.err(341): at android.widget.SimpleAdapter.getView(SimpleAdapter.java:114)
12-27 11:56:56.378: WARN/System.err(341): at com.presentation.activity.ShowListActivity$CustomAdapter.getView(ShowListActivity.java:229)
12-27 11:56:56.378: WARN/System.err(341): at android.widget.AbsListView.obtainView(AbsListView.java:1430)
12-27 11:56:56.386: WARN/System.err(341): at android.widget.ListView.makeAndAddView(ListView.java:1745)
12-27 11:56:56.386: WARN/System.err(341): at android.widget.ListView.fillDown(ListView.java:670)
12-27 11:56:56.386: WARN/System.err(341): at android.widget.ListView.fillFromTop(ListView.java:727)
12-27 11:56:56.386: WARN/System.err(341): at android.widget.ListView.layoutChildren(ListView.java:1598)
12-27 11:56:56.386: WARN/System.err(341): at android.widget.AbsListView.onLayout(AbsListView.java:1260)
12-27 11:56:56.386: WARN/System.err(341): at android.view.View.layout(View.java:7175)
12-27 11:56:56.386: WARN/System.err(341): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
12-27 11:56:56.386: WARN/System.err(341): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
12-27 11:56:56.386: WARN/System.err(341): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
12-27 11:56:56.396: WARN/System.err(341): at android.view.View.layout(View.java:7175)
12-27 11:56:56.396: WARN/System.err(341): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
12-27 11:56:56.396: WARN/System.err(341): at android.view.View.layout(View.java:7175)
12-27 11:56:56.396: WARN/System.err(341): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
12-27 11:56:56.396: WARN/System.err(341): at android.view.View.layout(View.java:7175)
12-27 11:56:56.396: WARN/System.err(341): at android.view.ViewRoot.performTraversals(ViewRoot.java:1140)
12-27 11:56:56.396: WARN/System.err(341): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
12-27 11:56:56.396: WARN/System.err(341): at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 11:56:56.396: WARN/System.err(341): at android.os.Looper.loop(Looper.java:123)
12-27 11:56:56.396: WARN/System.err(341): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-27 11:56:56.396: WARN/System.err(341): at java.lang.reflect.Method.invokeNative(Native Method)
12-27 11:56:56.396: WARN/System.err(341): at java.lang.reflect.Method.invoke(Method.java:507)
12-27 11:56:56.396: WARN/System.err(341): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-27 11:56:56.406: WARN/System.err(341): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-27 11:56:56.406: WARN/System.err(341): at dalvik.system.NativeStart.main(Native Method)
12-27 11:56:56.466: WARN/System.err(341): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-27 11:56:56.406: WARN/System.err(341): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-27 11:56:56.466: DEBUG/skia(341): ---- read threw an exception
12-27 11:56:56.466: DEBUG/skia(341): --- SkImageDecoder::Factory returned null
12-27 11:56:56.466: INFO/System.out(341): resolveUri failed on bad bitmap uri:
I am using a custom adapter that extends the SimpleAdapter and putting the text and icons according to condition.
My custome adapter looks something like..
serviceAdapter = new CustomAdapter(this, serviceList, R.layout.list_row,
new String[] { "name", "duration","reason", "remark", "img1", "img2", "img3",
"img" }, new int[] { R.id.servicename, R.id.duration,R.id.reason, R.id.remark,
R.id.statusImg1, R.id.statusImg2, R.id.statusImg3, R.id.isExpandable });
I am putting the corresponding values from a HashMap...
HashMap<String, Object> rowValue = new HashMap<String, Object>();
And image using. rowValue.put("img2", R.drawable.img);
Its not throwing any errors but slowing down the application a lot. Can any one let me know what the problem might be...
Check for the image name in image path. The issue may be in image path. I am sure that it points to any directory not to file.
maybe the problem is: the image file path pointer to a folder not file
I have an android programm which manage a database. It this database, I write the sensor values of my device.
When close the application with the home button, i have a force close error.
Here is my logcat, can you please help me, thank you.
`12-27 10:45:20.827: D/AndroidRuntime(1053): Shutting down VM
12-27 10:45:20.827: W/dalvikvm(1053): threadid=1: thread exiting with uncaught exception (group=0x40014760)
12-27 10:45:20.942: E/AndroidRuntime(1053): FATAL EXCEPTION: main
12-27 10:45:20.942: E/AndroidRuntime(1053): java.lang.NullPointerException
12-27 10:45:20.942: E/AndroidRuntime(1053): at android.database.sqlite.SQLiteStatement.releaseAndUnlock(SQLiteStatement.java:283)
12-27 10:45:20.942: E/AndroidRuntime(1053): at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:116)
12-27 10:45:20.942: E/AndroidRuntime(1053): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1732)
12-27 10:45:20.942: E/AndroidRuntime(1053): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1605)
12-27 10:45:20.942: E/AndroidRuntime(1053): at milos.stationdemesure.CapteursBDD.insertValeursCapteur(CapteursBDD.java:69)
12-27 10:45:20.942: E/AndroidRuntime(1053): at milos.stationdemesure.EssaisCapteurs.onProximityChanged(EssaisCapteurs.java:454)
12-27 10:45:20.942: E/AndroidRuntime(1053): at milos.stationdemesure.EssaisCapteurs.onSensorChanged(EssaisCapteurs.java:354)
12-27 10:45:20.942: E/AndroidRuntime(1053): at android.hardware.SensorManager$ListenerDelegate$1.handleMessage(SensorManager.java:529)
12-27 10:45:20.942: E/AndroidRuntime(1053): at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 10:45:20.942: E/AndroidRuntime(1053): at android.os.Looper.loop(Looper.java:126)
12-27 10:45:20.942: E/AndroidRuntime(1053): at android.app.ActivityThread.main(ActivityThread.java:3997)
12-27 10:45:20.942: E/AndroidRuntime(1053): at java.lang.reflect.Method.invokeNative(Native Method)
12-27 10:45:20.942: E/AndroidRuntime(1053): at java.lang.reflect.Method.invoke(Method.java:491)
12-27 10:45:20.942: E/AndroidRuntime(1053): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
12-27 10:45:20.942: E/AndroidRuntime(1053): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
12-27 10:45:20.942: E/AndroidRuntime(1053): at dalvik.system.NativeStart.main(Native Method)
`
I feel the issue is either database instance or any other object became null but you are calling some method using that object. Always check for null before using any methods of any object. see the sample example
example
if(database != null){
database.close();
}
Looks similar to this issue: SQLiteDatabase close() function causing NullPointerException when multiple threads
You may not need to call database.close()
i have a spinner and when you select an item from the spinner a text from a string should show in the textView, (txtdescription1) but when i start the activity it crashes.
i have tested a lot of thing but i dont find a error in the code.
Resources res = getResources();
int[] txt = res.getIntArray(R.array.description);
public void onItemSelected(AdapterView<?> parent, View v, int position,
long id) {
txtdescription1.setText(txt[position]);
}
Here is the LogCat
12-27 00:37:24.895: E/AndroidRuntime(1267): FATAL EXCEPTION: main
12-27 00:37:24.895: E/AndroidRuntime(1267): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.alpha.liveshit/com.alpha.liveshit.Sample}: java.lang.NullPointerException
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.os.Looper.loop(Looper.java:123)
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-27 00:37:24.895: E/AndroidRuntime(1267): at java.lang.reflect.Method.invokeNative(Native Method)
12-27 00:37:24.895: E/AndroidRuntime(1267): at java.lang.reflect.Method.invoke(Method.java:521)
12-27 00:37:24.895: E/AndroidRuntime(1267): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-27 00:37:24.895: E/AndroidRuntime(1267): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-27 00:37:24.895: E/AndroidRuntime(1267): at dalvik.system.NativeStart.main(Native Method)
12-27 00:37:24.895: E/AndroidRuntime(1267): Caused by: java.lang.NullPointerException
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.content.ContextWrapper.getResources(ContextWrapper.java:80)
12-27 00:37:24.895: E/AndroidRuntime(1267): at com.alpha.liveshit.Sample.<init>(Sample.java:42)
12-27 00:37:24.895: E/AndroidRuntime(1267): at java.lang.Class.newInstanceImpl(Native Method)
12-27 00:37:24.895: E/AndroidRuntime(1267): at java.lang.Class.newInstance(Class.java:1429)
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
12-27 00:37:24.895: E/AndroidRuntime(1267): ... 11 more
You appear to be calling getResources() from your activity's constructor. Your activity should not have a constructor (or, at least, not one that interacts with the framework in any way). It hasn't been properly initialized at that point (which is why the call to getResources() is throwing a NPE). Put all your initialization code in onCreate(Bundle).
Im trying to inflate a view which serves as a loading screen for my glSurfaceView while it swaps out textures during runtime (i know how to do it during my onCreate just fine). Its just a RelativeLayout with a progress bar in the middle and when its done with the swap it disappears, but its not inflating correctly.
inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
loading = inflater.inflate(R.layout.loading,null);
RelativeLayout loadingScreen = (RelativeLayout) findViewById(R.id.loadingScreen);
where loadingScreen is the id of the relative layout.
xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/loadingScreen"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:visibility="visible" >
<ProgressBar
android:id="#+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
</ProgressBar>
<EditText
android:id="#+id/editText android:layout_height="
android:layout_width="wrap_content"
wrap_content="" >
</EditText>
</RelativeLayout>
For a test, I added an EditText above the following additional code to test it out:
EditText tester = (EditText) findViewById(R.id.editText); //Now we have an object
tester.setText("dfdfds");
and the error log:
08-12 15:07:35.630: ERROR/ActivityThread(2502): Failed to inflate
08-12 15:07:35.630: ERROR/ActivityThread(2502): android.view.InflateException: Binary XML file line #5: Error inflating class com.huskybus.CampusMapOpenGL
08-12 15:07:35.630: ERROR/ActivityThread(2502): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:212)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at android.app.Activity.setContentView(Activity.java:1657)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at com.huskybus.Main.onCreate(Main.java:91)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at android.os.Handler.dispatchMessage(Handler.java:99)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at android.os.Looper.loop(Looper.java:130)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at android.app.ActivityThread.main(ActivityThread.java:3835)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at java.lang.reflect.Method.invokeNative(Native Method)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at java.lang.reflect.Method.invoke(Method.java:507)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at dalvik.system.NativeStart.main(Native Method)
08-12 15:07:35.630: ERROR/ActivityThread(2502): Caused by: java.lang.reflect.InvocationTargetException
08-12 15:07:35.630: ERROR/ActivityThread(2502): at java.lang.reflect.Constructor.constructNative(Native Method)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
08-12 15:07:35.630: ERROR/ActivityThread(2502): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
08-12 15:07:35.630: ERROR/ActivityThread(2502): ... 21 more
08-12 15:07:35.630: ERROR/ActivityThread(2502): Caused by: java.lang.NullPointerException
08-12 15:07:35.630: ERROR/ActivityThread(2502): at com.huskybus.CampusMapOpenGL.<init>(CampusMapOpenGL.java:101)
08-12 15:07:35.630: ERROR/ActivityThread(2502): ... 24 more
08-12 15:07:35.637: DEBUG/AndroidRuntime(2502): Shutting down VM
08-12 15:07:35.637: WARN/dalvikvm(2502): threadid=1: thread exiting with uncaught exception (group=0x40015560)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): FATAL EXCEPTION: main
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.huskybus/com.huskybus.Main}: android.view.InflateException: Binary XML file line #5: Error inflating class com.huskybus.CampusMapOpenGL
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at android.os.Handler.dispatchMessage(Handler.java:99)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at android.os.Looper.loop(Looper.java:130)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at android.app.ActivityThread.main(ActivityThread.java:3835)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at java.lang.reflect.Method.invokeNative(Native Method)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at java.lang.reflect.Method.invoke(Method.java:507)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at dalvik.system.NativeStart.main(Native Method)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class com.huskybus.CampusMapOpenGL
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:212)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at android.app.Activity.setContentView(Activity.java:1657)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at com.huskybus.Main.onCreate(Main.java:91)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): ... 11 more
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): Caused by: java.lang.reflect.InvocationTargetException
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at java.lang.reflect.Constructor.constructNative(Native Method)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): ... 21 more
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): Caused by: java.lang.NullPointerException
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): at com.huskybus.CampusMapOpenGL.<init>(CampusMapOpenGL.java:101)
08-12 15:07:35.653: ERROR/AndroidRuntime(2502): ... 24 more
Try loading.findViewById(...) instead of just findViewById(...)
i also have these kind of errors.i found that the error is come because of my text editor name is not match with the my text editor id.
When you have inflatet the View you need to use that view when finding child views like this
inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
loading = inflater.inflate(R.layout.loading,null);
RelativeLayout loadingScreen = (RelativeLayout) loading.findViewById(R.id.loadingScreen);