0

パスティの 98 行目で NullPointerException を取得し、locate の 191 行目に相当しますimageLoader.displayImage((String) myArr.get(position).get("image_url"), imageView, options, new SimpleImageLoadingListener()..

私が保存するすべての私のURLArrayList<HashMap<String, Object>>

完全なコードhttp://pastie.org/7108410#94

エラー

    03-25 16:39:33.382: E/AndroidRuntime(18178): FATAL EXCEPTION: main
03-25 16:39:33.382: E/AndroidRuntime(18178): java.lang.NullPointerException
03-25 16:39:33.382: E/AndroidRuntime(18178):    at com.camitss.phnompenhcafe.ImagePagerActivity$ImagePagerAdapter.instantiateItem(ImagePagerActivity.java:191)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:801)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.support.v4.view.ViewPager.populate(ViewPager.java:930)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.support.v4.view.ViewPager.populate(ViewPager.java:881)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1366)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.View.measure(View.java:15479)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.View.measure(View.java:15479)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.View.measure(View.java:15479)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4824)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.View.measure(View.java:15479)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4824)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.View.measure(View.java:15479)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4824)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2359)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.View.measure(View.java:15479)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1966)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1212)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1385)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1105)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4452)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.Choreographer.doCallbacks(Choreographer.java:555)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.Choreographer.doFrame(Choreographer.java:525)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.os.Handler.handleCallback(Handler.java:615)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.os.Handler.dispatchMessage(Handler.java:92)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.os.Looper.loop(Looper.java:137)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at android.app.ActivityThread.main(ActivityThread.java:4895)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at java.lang.reflect.Method.invokeNative(Native Method)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at java.lang.reflect.Method.invoke(Method.java:511)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
03-25 16:39:33.382: E/AndroidRuntime(18178):    at dalvik.system.NativeStart.main(Native Method)
4

2 に答える 2

3

あなたImageLoader imageLoaderは常にnullです。初期化する必要があります。

置き換えてみてください:

ImageLoader imageLoader;

ImageLoader imageLoader = ImageLoader.getInstance();
于 2013-03-25T09:53:13.987 に答える
1
  1. 98 行目にブレークポイントを設定し、imageView が null でないことを確認します。
  2. 行 98 の前にデバッグ ログ メッセージを追加し、myArr.get(position).get("image_url") を出力して、これが有効な URL であり、実際に null でないかどうかを確認します。
  3. ブレークポイントを設定するときは、imageLoader が null でないことを確認してください

Eclipse でデバッグする方法については、この SO の質問と以下の回答を参照することをお勧めします。

于 2013-03-25T10:19:04.257 に答える