我正在通过这个链接实现下面的代码Android-AutoCompleteTextView仅在后退时工作
但是我有错误。我已经发布了下面的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;
}
}
但我想这是不对的。请帮我解决这个问题:使用新的谷歌API而不是旧的。我真的很感激任何帮助。提前感谢。
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)
您发送链接到的代码一团糟,请参阅我在本线程中的回答如何在保留字符状态的情况下向自动完成文本视图动态添加建议