我正在开发一个Android应用程序来获取数据。它崩溃了,我得到一个NullPointerException。任何人都可以帮我编辑我的代码/列出我的错误吗?
这是一种崩溃的方法 private void ClaimCategory(){
final ArrayList<ClaimModel> claimModels = new ArrayList<ClaimModel>();
claimModels.equals(AareonLocataireManager.getInstance().getClaims());
ArrayList<String> alist = new ArrayList<String>();
claimCategoryModel = new ArrayList<>();
alist.add(getActivity().getString(R.string.Mob_my_claim_category));
claimCategoryModel = AareonLocataireManager.getInstance().getClaimCategoryModelsObject();
// Création d'une ListIterator
ListIterator itr = claimCategoryModel.listIterator();
int i = 0;
// Afficher le contenu à l'aide de 'ListIterator'
while (itr.hasNext()) {
if (i == 2) break;
alist.add(
claimCategoryModel.get(i).getLIBELLE());
i++;
}
ArrayAdapter<String> catAdapter = initSpinnerValues(alist);
catAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
categoriesSpinner.setAdapter(catAdapter);
}
这是我的logcat
11-09 19:02:10.646 30715-30715/fr.aareon.saumur E/AndroidRuntime: FATAL EXCEPTION: main Process: fr.aareon.saumur, PID: 30715
java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.ListIterator java.util.ArrayList.listIterator()' on a null object reference
at fr.aareon.saumur.fragments.AddClaimFragment.ClaimCategory(AddClaimFragment.java:519)
at fr.aareon.saumur.fragments.AddClaimFragment.afterViews(AddClaimFragment.java:235)
at fr.aareon.saumur.fragments.AddClaimFragment_.onViewChanged(AddClaimFragment_.java:144)
at org.androidannotations.api.view.OnViewChangedNotifier.notifyViewChanged(OnViewChangedNotifier.java:41)
at fr.aareon.saumur.fragments.AddClaimFragment_.onViewCreated(AddClaimFragment_.java:101)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1314)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:757)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2355)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2146)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2098)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2008)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:763)
at fr.aareon.saumur.activities.DashboardActivity.changeFragment(DashboardActivity.java:171)
at fr.aareon.saumur.activities.DashboardActivity$3.run(DashboardActivity.java:185)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)