Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid EntryAdapter crashing on super()
    primarykey
    data
    text
    <p>I'm trying to pull some information from the web in my app. Network interaction can't be done in the MainActivity, so I've got an instance of Runnable going to handle this. However, since I started that, I've been getting a null pointer exception. LogCat is pointing me at these chunks of code:</p> <pre><code>public CelebrityEntryAdapter(Activity context, List&lt;CelebrityEntry&gt; list) { super(context, R.layout.activity_celebrity, list); this.context = context; this.list = list; } </code></pre> <p>and here (at the "adapter = new CelebrityEntryAdapter..." line):</p> <pre><code>public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); context = this; filterText = (EditText) getView().findViewById(R.id.search_box); filterText.addTextChangedListener(filterTextWatcher); new Thread(new Runnable(){ public void run() { try { adapter = new CelebrityEntryAdapter(context.getActivity(), populate()); } catch (IOException e) { e.printStackTrace(); } setListAdapter(adapter); filterTextWatcher = new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); } }; } }).start(); } </code></pre> <p>What do you think?</p> <p>EDIT:</p> <p>Here's logcat:</p> <p>05-01 18:49:36.391: E/AndroidRuntime(1468): FATAL EXCEPTION: Thread-109<br> 05-01 18:49:36.391: E/AndroidRuntime(1468): java.lang.NullPointerException<br> 05-01 18:49:36.391: E/AndroidRuntime(1468): at android.widget.ArrayAdapter.init(ArrayAdapter.java:310)<br> 05-01 18:49:36.391: E/AndroidRuntime(1468): at android.widget.ArrayAdapter.(ArrayAdapter.java:153)<br> 05-01 18:49:36.391: E/AndroidRuntime(1468): at edu.Drake.doppelganger.CelebrityEntryAdapter.(CelebrityEntryAdapter.java:31)<br> 05-01 18:49:36.391: E/AndroidRuntime(1468): at edu.Drake.doppelganger.CelebritiesFragment$1.run(CelebritiesFragment.java:60)<br> 05-01 18:49:36.391: E/AndroidRuntime(1468): at java.lang.Thread.run(Thread.java:856)</p> <p>Here's populate():</p> <pre><code>public List&lt;CelebrityEntry&gt; populate() throws IOException { List&lt;CelebrityEntry&gt; list = new ArrayList&lt;CelebrityEntry&gt;(); HttpGet httppost = new HttpGet("http://www.ethanclevenger.com/MirrorMe/celebrity-master.txt"); HttpResponse response = httpclient.execute(httppost); HttpEntity ht = response.getEntity(); BufferedHttpEntity buf = new BufferedHttpEntity(ht); InputStream is = buf.getContent(); BufferedReader r = new BufferedReader(new InputStreamReader(is)); String name; String url; while ((name = r.readLine()) != null) { url = r.readLine(); Log.v(url, url); list.add(new CelebrityEntry(name, url)); } return list; } </code></pre> <p>Sorry for the awful logcat formatting - trying to figure that out. I've been able to log both "url" and "name" from "populate()" - it's definitely retrieving it.</p> <p>For good measure, here's the constructor:</p> <pre><code>public CelebrityEntry(String name, String pic) { this.name = name; this.pic = pic; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload