1

ユーザが検索フィールドに入力を開始するときに、段落(文字列)に一致する用語に基づいてオートコンプリートオプションを表示したいので、小さな電話キーボードを使用して実際に長い用語を入力する必要はありません。アンドロイドのオートコンプリートで検索候補を表示するには?

注:

提案は、次のリンクは、あなたが一緒に始めるべきでAndroidデベロッパーフォーラムのためにある特定のコンテンツや文字列

+0

どのアダプターを使用していますか? – pskink

+1

このチュートリアルを試すhttps://www.tutorialspoint.com/android/android_auto_complete.htm –

+0

アダプターにフィルターコードを投稿してください。ライブラリー – Nithinlal

答えて

0

から来ます。リンク:https://developer.android.com/reference/android/widget/AutoCompleteTextView.html

例ユーザーが入力している間、様々な国の名前を示唆してテキストビューを作成するためのリンクで提供される:

public class CountriesActivity extends Activity { 
    protected void onCreate(Bundle icicle) { 
     super.onCreate(icicle); 
     setContentView(R.layout.countries); 

     //initialise the adapter for give n array of strings to be searched with 
     ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, 
        android.R.layout.simple_dropdown_item_1line, COUNTRIES); 
     AutoCompleteTextView autotextView = (AutoCompleteTextView) 
       findViewById(R.id.countries_list); 

     //set the adapter for the Autocomplete TextView 
     autotextView.setAdapter(adapter); 
    } 

    private static final String[] COUNTRIES = new String[] { 
     "Belgium", "France", "Italy", "Germany", "Spain" 
    }; 
} 
+0

を使用している場合は、 autocompletetextview'タグ? – pskink

+0

@kaushik彼はすでにそれを参照してください – Nithinlal

+0

ああ、私の悪い。私はそれを変更させてください。 @pskink –

0

autoCompleteTextView

<AutoCompleteTextView 
android:id="@+id/autoCompleteTextView1"  
android:layout_width="wrap_content"  
android:layout_height="wrap_content"> 
を含むレイアウトを作成し、これを試してみてください

javaコードでは、配列内のすべての提案を表示します。

String[] suggestions ={"Android","java"}; 

//or get it via array.xml of res, using 
//String[] suggestions = getResources().getStringArray(R.array.suggarray); 

text=(AutoCompleteTextView)findViewById(R.id.autoCompleteTextView1); 

ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,suggestions); 

text.setAdapter(adapter); 
text.setThreshold(1); 
関連する問題