自动完成谷歌地址在Android中崩溃

时间:2013-12-06 11:45:13

标签: android google-api autocompletetextview

我正在通过此链接Android - AutoCompleteTextView only works when backspacing

实施以下代码

但是我收到了错误。我在下面发布了logcat错误:

我也创建了课程:

public class SimpleAddress {

    public SimpleAddress(String formatted_address, Double lat, Double lng) {
        // TODO Auto-generated constructor stub
    }

    public String getFormatted_address() {
        // TODO Auto-generated method stub
        return null;
    }

}

但我猜它不正确。请帮我解决这个问题:使用新的googleapis而不是旧的。我非常感谢任何帮助。谢谢你。

Logcat错误:

  FATAL EXCEPTION: main
 Process: , PID: 498
 java.lang.NullPointerException
    at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:394)
    at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
    at android.widget.AbsListView.obtainView(AbsListView.java:2263)
    at android.widget.ListPopupWindow$DropDownListView.obtainView(ListPopupWindow.java:1585)
    at android.widget.ListView.measureHeightOfChildren(ListView.java:1263)
    at android.widget.ListPopupWindow.buildDropDown(ListPopupWindow.java:1167)
    at android.widget.ListPopupWindow.show(ListPopupWindow.java:554)
    at android.widget.AutoCompleteTextView.showDropDown(AutoCompleteTextView.java:1096)
    at .MainActivity$AdapterUpdaterTask.onPostExecute(MainActivity.java:190)
    at .MainActivity$AdapterUpdaterTask.onPostExecute(MainActivity.java:1)
    at android.os.AsyncTask.finish(AsyncTask.java:632)
    at android.os.AsyncTask.access$600(AsyncTask.java:177)
    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4998)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
    at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:1)

您发送链接的代码是一个很大的混乱,请在此主题中查看我的答案How to dynamically add suggestions to autocompletetextview with preserving character status