Skip to content Skip to sidebar Skip to footer

Why Am I Receiving A Fatal Exception?

I am new to android and I am trying to create a list view using an array adapter, a run method and multi threading, but I'm receiving the following error: 07-14 19:00:15.605 2931

Solution 1:

Looks like "summary" is null. Check for null before creating and setting the adapter.

if (summary == null) {
    // handle the error
    Toast.makeText(this, "Error: no result", Toast.LENGTH_LONG).show();
} else {
    StorylineAdapteradapter=newStorylineAdapter(MainActivity.this, R.layout.item_storyline, summary);
    mEditTextResponse.setAdapter(adapter);
}

Solution 2:

You should add a getCount method to your adapter. That might look something like this:

publicclassStorylineAdapterextendsArrayAdapter<SummaryData>{
//Keep your other methods as they stand
...

@Override
publicintgetCount()
{
   if (summary!=null)
   {
   return summary.size();
   }
   else
   {
   Log.e("Adapter","Summary array is null");
   return0;
   }
}

Post a Comment for "Why Am I Receiving A Fatal Exception?"