Note that there are some explanatory texts on larger screens.

plurals
  1. POAutoCompleteTextView (ArrayAdapter) NullPointerException in PhoneGap
    primarykey
    data
    text
    <p>I'm adapting an old WebOS app to android and I'm using phonegap for nearly all of it (since the old code was javascript, this is convenient), but I wish to use a native AutoCompleteTextView for input. I'm getting a NullPointerException, probably due to my exotic hybrid app. But let me start at the beginning. I appended a footer (per a post I found here) like so</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.loadUrl("file:///android_asset/www/index.html"); /* ... boring things here ... */ // http://stackoverflow.com/questions/7320910/android-phonegap-with-native-controls View footer = View.inflate(getContext(), R.layout.footer, null); root.addView( footer ); // setContentView(root); // http://www.kwpro.net/blogs/2011/1/10/1651_Android_AutoComplete_Tutorial_Amendment.html } </code></pre> <p>I found some notes on a blog that suggested the solution to my problem might be to setContentView, but that doesn't seem to work. Anyway, I set the autocomplete text exactly once from javascript using this (via window.f.setAutoComplete() through a java interface).</p> <pre><code>public void setAutoComplete(String []s) { Log.d(TAG, "[native]: setting autocomplete text"); AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.inpu); ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.list_item, s); textView.setAdapter(adapter); } </code></pre> <p>Anyway, everything seems to work. That is, the list of choices pops up and you can sometimes pick one (sometimes) before I get a NullPointerException that force closes the app. I feel ill equipped to deal with this one, so I thought I'd ask in public.</p> <p>The exception dump looks like this:</p> <pre><code>W/dalvikvm( 1832): threadid=11: thread exiting with uncaught exception (group=0x409c01f8) E/AndroidRuntime( 1832): FATAL EXCEPTION: WebViewCoreThread E/AndroidRuntime( 1832): java.lang.NullPointerException E/AndroidRuntime( 1832): at android.widget.AbsListView$RecycleBin.getScrapView(AbsListView.java:5900) E/AndroidRuntime( 1832): at android.widget.AbsListView.obtainView(AbsListView.java:2003) E/AndroidRuntime( 1832): at android.widget.ListPopupWindow$DropDownListView.obtainView(ListPopupWindow.java:1168) E/AndroidRuntime( 1832): at android.widget.ListView.measureHeightOfChildren(ListView.java:1244) E/AndroidRuntime( 1832): at android.widget.ListPopupWindow.buildDropDown(ListPopupWindow.java:1095) E/AndroidRuntime( 1832): at android.widget.ListPopupWindow.show(ListPopupWindow.java:524) E/AndroidRuntime( 1832): at android.widget.AutoCompleteTextView.showDropDown(AutoCompleteTextView.java:1062) E/AndroidRuntime( 1832): at android.widget.AutoCompleteTextView.updateDropDownForFilter(AutoCompleteTextView.java:939) E/AndroidRuntime( 1832): at android.widget.AutoCompleteTextView.onFilterComplete(AutoCompleteTextView.java:921) E/AndroidRuntime( 1832): at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:285) E/AndroidRuntime( 1832): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 1832): at android.os.Looper.loop(Looper.java:137) E/AndroidRuntime( 1832): at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:728) E/AndroidRuntime( 1832): at java.lang.Thread.run(Thread.java:856) </code></pre> <p>My best guess is that I'm running into that "only one thread can do UI stuff" ... ahh ... paradigm, but I'm not sure how to approach fixing that if that's the case, and if that's not the case, I have no idea what to try next.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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