I really don't know what to do anymore...
I got this code (tried many before):
final LoaderImageView image = (LoaderImageView) findViewById(R.id.loaderImageView);
image.setImageDrawable(getAnImageUrl()); *<--- is line 119, where logcat say the NullPointer is*emphasized text*
private String getAnImageUrl() {
return "http://i.imgur.com/n6jBV.jpg";
}
This should show an image, I also tried many other ways I found on the internet, But it always says:
08-15 12:37:57.770: E/AndroidRuntime(19455): FATAL EXCEPTION: main
08-15 12:37:57.770: E/AndroidRuntime(19455): java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.dlv.listactivity/com.dlv.listactivity.MainActivity}: java.lang.NullPointerException
08-15 12:37:57.770: E/AndroidRuntime(19455): at android.app.ActivityThread.performLaunchActivity
(ActivityThread.java:1651)
08-15 12:37:57.770: E/AndroidRuntime(19455): at android.app.ActivityThread.handleLaunchActivity
(ActivityThread.java:1667)
08-15 12:37:57.770: E/AndroidRuntime(19455): at android.app.ActivityThread.access$1500
(ActivityThread.java:117)
08-15 12:37:57.770: E/AndroidRuntime(19455): at android.app.ActivityThread$H.handleMessage
(ActivityThread.java:935)
08-15 12:37:57.770: E/AndroidRuntime(19455): at android.os.Handler.dispatchMessage(Handler.java:99)
08-15 12:37:57.770: E/AndroidRuntime(19455): at android.os.Looper.loop(Looper.java:123)
08-15 12:37:57.770: E/AndroidRuntime(19455): at android.app.ActivityThread.main
(ActivityThread.java:3691)
08-15 12:37:57.770: E/AndroidRuntime(19455): at java.lang.reflect.Method.invokeNative(Native
Method)
08-15 12:37:57.770: E/AndroidRuntime(19455): at java.lang.reflect.Method.invoke(Method.java:507)
08-15 12:37:57.770: E/AndroidRuntime(19455): at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:847)
08-15 12:37:57.770: E/AndroidRuntime(19455): at com.android.internal.os.ZygoteInit.main
(ZygoteInit.java:605)
08-15 12:37:57.770: E/AndroidRuntime(19455): at dalvik.system.NativeStart.main(Native Method)
08-15 12:37:57.770: E/AndroidRuntime(19455): Caused by: java.lang.NullPointerException
08-15 12:37:57.770: E/AndroidRuntime(19455): at com.dlv.listactivity.MainActivity.onCreate
(MainActivity.java:119)
08-15 12:37:57.770: E/AndroidRuntime(19455): at android.app.Instrumentation.callActivityOnCreate
(Instrumentation.java:1047)
08-15 12:37:57.770: E/AndroidRuntime(19455): at android.app.ActivityThread.performLaunchActivity
(ActivityThread.java:1615)
About that he gets a NullPointer.
I also already give permission to the internet (Tried every single one of them I found on the internet by now):
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.DELETE_CACHE_FILES">
And this is my list.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<com.dlv.listactivity.LoaderImageView
android:id="@+id/loaderImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<!-- image="http://developer.android.com/images/dialog_buttons.png" -->
<ImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" android:layout_gravity="left|center_vertical" android:textSize="20dip" android:layout_marginLeft="10dip"/>
</LinearLayout>
I use a listActivity
(instead of the normal Activity
), and I got 2 xml's that I combine with inflate
.
I even got other projects where I can download/show picture from the internet... But this one doesn't and I can't find the problem...
Can the inflate be a problem? or something else?
Please give me some suggestions.
Thanks Already, Bigflow