例外
09-09 23:55:25.336: E/AndroidRuntime(14983): java.lang.NullPointerException
09-09 23:55:25.336: E/AndroidRuntime(14983): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:353)
09-09 23:55:25.336: E/AndroidRuntime(14983): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
09-09 23:55:25.336: E/AndroidRuntime(14983): at android.widget.AbsListView.obtainView(AbsListView.java:1430)
09-09 23:55:25.336: E/AndroidRuntime(14983): at android.widget.AutoCompleteTextView$DropDownListView.obtainView(AutoCompleteTextView.java:1656)
09-09 23:55:25.336: E/AndroidRuntime(14983): at android.widget.ListView.measureHeightOfChildren(ListView.java:1264)
代码
fromAutoComplete = new AutoComplete(
this, // R.layout.fromautocomplete,
android.R.layout.simple_list_item_single_choice,
R.id.fromautocomplete);
fromAutoComplete.setNotifyOnChange(true);
fromAddress = (AutoCompleteTextView) findViewById(R.id.fromAddress);
fromAddress.setAdapter(fromAutoComplete);
fromAddress.setOnItemClickListener(this);
fromAddress.setOnFocusChangeListener(this);
fromAddress.setOnClickListener(this);
toAutoComplete = new AutoComplete(this,
android.R.layout.simple_list_item_single_choice,
// R.layout.toautocomplete,
R.id.toautocomplete);
toAutoComplete.setNotifyOnChange(true);
toAddress = (AutoCompleteTextView) findViewById(R.id.toAddress);
toAddress.setAdapter(toAutoComplete);
toAddress.setOnItemClickListener(this);
toAddress.setOnFocusChangeListener(this);
toAddress.setOnClickListener(this);
自动完成(一些相关的代码行)
public class AutoComplete extends ArrayAdapter<String> implements Filterable {
public AutoComplete(Activity activity, int layout, int textViewResourceId) {
super(activity, layout, textViewResourceId);
//super(activity, textViewResourceId);
}
结果
显然这是一个自动完成的东西,所以它不会在代码中崩溃,而是在通货膨胀
编辑:通过
解决问题 toAutoComplete = new AutoComplete(this,
R.layout.toautocomplete,
R.id.toautocomplete);
fromAutoComplete = new AutoComplete(
this, R.layout.fromautocomplete,
R.id.fromautocomplete);
答案 0 :(得分:0)
编辑:通过
解决问题toAutoComplete = new AutoComplete(this,
R.layout.toautocomplete,
R.id.toautocomplete);
fromAutoComplete = new AutoComplete(
this, R.layout.fromautocomplete,
R.id.fromautocomplete);