Xuni コントロール > Input > AutoComplete > クイックスタート:Xuni AutoComplete へのデータの挿入 |
このセクションでは、XuniAutoComplete コントロールを Android アプリケーションに追加し、そのコントロールにデータを挿入する方法を説明します。このトピックは 3 つの手順で構成されます。
次の図は、ユーザーがテキストを入力したときに、XuniAutoComplete コントロールがドロップダウンリストに候補リストをどのように提供するかを示しています。
Java |
コードのコピー
|
---|---|
public class DropDownItem { public String name; public String value; static String[] country = { "アフガニスタン", "中国", "インド", "日本", "ネパール", "北朝鮮", "パキスタン", "韓国", "スリランカ" }; DropDownItem(String name, String value) { this.name = name; this.value = value; } static ObservableList<DropDownItem> getList() { ObservableList<DropDownItem> list = new ObservableList<DropDownItem>(); for (int i = 0; i < country.length; i++) { list.add(new DropDownItem(country[i], i + "")); } return list; } } |
Java |
コードのコピー
|
---|---|
import com.grapecity.xuni.core.ObservableList; import com.grapecity.xuni.input.autocomplete.MatchType; import com.grapecity.xuni.input.autocomplete.XuniAutoCompleteTextView; |
XML |
コードのコピー
|
---|---|
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:columnCount="2" android:paddingBottom="20dp" android:paddingLeft="20dp" android:paddingRight="20dp" android:paddingTop="20dp" android:rowCount="4" > <com.grapecity.xuni.input.autocomplete.XuniAutoCompleteTextView android:id="@+id/autocomplete_highlight" android:layout_width="300dp" android:layout_height="wrap_content"> </com.grapecity.xuni.input.autocomplete.XuniAutoCompleteTextView> </GridLayout> |
Java |
コードのコピー
|
---|---|
public class MainActivity extends Activity { ObservableList<DropDownItem> dataSource; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); XuniAutoCompleteTextView highLightAutoComplete = (XuniAutoCompleteTextView) this.findViewById(R.id.autocomplete_highlight); highLightAutoComplete.setItemsSource(DropDownItem.country); highLightAutoComplete.setMatchType(MatchType.CONTAINS); highLightAutoComplete.setThreshold(1); } } |
パッケージエクスプローラーで、アプリケーションを右クリックし、[実行]→[Android アプリケーション]を選択します。