AutoCompleteTextViewを使用してListActivityを作成しようとしています。Listviewには、ImageViewと2つのTextViewで構成されるlistItemsがあります。オートコンプリート文字列を除いて、すべてがうまく機能します。ArrayAdapterを使用していますが、文字列(COUNTRIES)を設定する方法がわかりません。ここにいくつかのコードがあります。
パブリッククラスSearchActivityはListActivityを拡張します{
static final String[] COUNTRIES = new String[] {
"Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra",
"Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina",
"Armenia", "Aruba", "Australia", "Austria", "Azerbaijan",
"Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium",
"Belize", "Benin", "Bermuda", "Bhutan", "Bolivia",
"Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory",
"British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burundi",
"Cote d'Ivoire", "Cambodia", "Cameroon", "Canada", "Cape Verde",
"Cayman Islands", "Central African Republic", "Chad", "Chile", "China",
"Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo",
"Cook Islands", "Costa Rica", "Croatia", "Cuba", "Cyprus", "Czech Republic"
};
private AutoCompleteTextView searchView;
private ListView mListView;
private ArrayList<MyItem> itemList = new ArrayList<MyItem>();
private ListItemAdapter searchListAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search);
searchView = (AutoCompleteTextView) findViewById(R.id.search_text);
searchView.setAdapter(searchListAdapter);
searchListAdapter = new ListItemAdapter(this, R.layout.search_row, itemList);
setListAdapter(searchListAdapter);
mListView = getListView();
mListView.setTextFilterEnabled(false);
}
/**
* This class is used to for the list objects.
*/
private class ListItemAdapter extends ArrayAdapter<MyItem> {
private ArrayList<MyItem> bevs;
private MyItem bevItem;
private TextView nameView;
private TextView descView;
private ImageView imageView;
public ListItemAdapter(Context context, int textViewResourceId,
ArrayList<MyItem> itemList) {
super(context, textViewResourceId, itemList);
this.bevs = itemList;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
/* Update the views */
return view;
}
}
}
正しい方向に向けてください
/乾杯エイドリアン