私はこのエラーを理解していません。次のように宣言Androidスタジオ - ListViewの競合へのArrayList
私の要素。
ListView listViewLocations;
private ArrayAdapter<String> listAdapter ;
ArrayList<Long> addressList = new ArrayList<Long>();
と内側のonCreate;
listViewLocations = (ListView) findViewById(R.id.listViewLocations);
ArrayList<Long> addresses = new ArrayList<>();
この場合、方法が画像に表示されます。
私のStacktraceでは、データの取得を確認するためにコードにコメントを付けてlog.iステートメントを追加して最終的なArrayListをログに記録し、配列として記録しています。
5-08 14:28:06.265 22794-22794/net.we4x4 I/myTag: [20.4203339/84.5712178, 62.4334592/94.5716614, 22.4214592/59.5711114]
単に私がリストビューで、この配列を置くしようとしていると私はこれを行う方法についての簡単なチュートリアルの後:その後、私は別の方法でのArrayListを宣言しようとした
http://windrealm.org/tutorials/android/android-listview.php
を。レッドラインを解決するための
ListView listViewLocations;
private ArrayAdapter<String> listAdapter ;
ArrayList addressList;
(エラーが絵で示されている)
と私は私のスタックトレースにこのエラーを得ました。
05-08 15:12:16.790 22349-22349/net.we4x4 E/AndroidRuntime: FATAL EXCEPTION: main
Process: net.we4x4, PID: 22349
java.lang.NullPointerException
at android.widget.ArrayAdapter.getCount(ArrayAdapter.java:330)
at android.widget.ListView.setAdapter(ListView.java:486)
at net.we4x4.GPSlocations.listAddresses(GPSlocations.java:228)
at net.we4x4.GPSlocations.access$000(GPSlocations.java:47)
at net.we4x4.GPSlocations$1.onClick(GPSlocations.java:93)
at android.view.View.performClick(View.java:4508)
at android.view.View$PerformClick.run(View.java:18675)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5584)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
競合が原因で実際にあなたが宣言gernicタイプ(文字列)とデータセットリスト –
Blackbelt
さて、現在のコードの間の不一致のあるを作成するのを忘れています私はレイアウトを修正して解決した別の問題に直面していたことを修正しました。スタックトレースにはtextViewが必要であり、現在のレイアウト "rowv_vid"に存在していましたが、別のレイアウトをそれにデータを渡すためにその中のtextViewだけが必要です。 – JanusJanus