LogCat entry meaning 2

前端 未结 1 1170
攒了一身酷
攒了一身酷 2021-01-29 16:11

I don\'t now the meaning of this LogCat entry. Can someone help me?

12-26 18:33:09.651: E/AndroidRuntime(26038): FATAL EXCEPTION: main
12-26 18:33:09.651: E/Andr         


        
1条回答
  •  南笙
    南笙 (楼主)
    2021-01-29 17:04

    java.lang.NullPointerException
        at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:394)
    
    ArrayAdapter adapter = 
        new ArrayAdapter(this, android.R.layout.simple_list_item_1, values);
    

    values has at least one null object in it, which you cannot have.


    You can read through the source code and see this happens here:

    T item = getItem(position);
    if (item instanceof CharSequence) {
        text.setText((CharSequence)item);
    } else {
        text.setText(item.toString()); // Line 394, when item is null this throws an NPE
    }
    

    0 讨论(0)
提交回复
热议问题