我在AlertDialog中有一个微调器。点击FloatingActionButton
时会显示。
final AlertDialog.Builder mBuilder = new AlertDialog.Builder(Main2Activity.this);
View mView = getLayoutInflater().inflate(R.layout.add_connection, null);
area = (Spinner) mView.findViewById(R.id.addArea);
和一个必须在微调器中显示的数组。
final ArrayList<String> areaList = (ArrayList<String>)getIntent().getSerializableExtra("areaList");("Outside the onclick function of FloatingActionButton")
ArrayAdapter<String> adapter = new ArrayAdapter<String>(Main2Activity.this, android.R.layout.simple_spinner_dropdown_item, areaList);
area.setAdapter(adapter);
现在,当我运行应用程序并单击FloatingActionButton
应用程序崩溃时,会出现以下错误。
java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
at android.widget.ArrayAdapter.getCount(ArrayAdapter.java:344)
at android.widget.AbsSpinner.setAdapter(AbsSpinner.java:115)
at android.widget.Spinner.setAdapter(Spinner.java:520)
at android.support.v7.widget.AppCompatSpinner.setAdapter(AppCompatSpinner.java:389)
at trickandroid.cablevasul.Main2Activity$1.onClick(Main2Activity.java:56)
at android.view.View.performClick(View.java:5637)
at android.view.View$PerformClick.run(View.java:22433)
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:6126)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
帮帮我..
答案 0 :(得分:0)
似乎target_link_libraries( your_projectSolution_name ${CUDA_LIBRARIES} ${CUDA_CUFFT_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_cupti_LIBRARY} ${CUDA_curand_LIBRARY} ${CUDA_cusparse_LIBRARY} ${CUDA_npp_LIBRARY} ${CUDA_nppc_LIBRARY} ${CUDA_nppi_LIBRARY} ${CUDA_npps_LIBRARY} ${CUDA_nvcuvenc_LIBRARY} ${CUDA_nvcuvid_LIBRARY})
返回getIntent().getSerializableExtra("areaList")
。您可以记录null
以查找是否为areaList
。
然后查看包含null
。{/ p>的Intent