2012-11-07 76 views
1

附加是其中有AutoCompleteTextView的圖像,我設置客戶名稱(字符串數組)的ArrayAdapter ..現在,我想通過客戶地址搜索客戶名稱(我有客戶名稱的字符串數組)客戶地址列表)。這意味着如果我在AutoCompleteTextView中鍵入「Ahemdabad」,它將顯示客戶名稱的地址爲「Ahemdabad」的列表。所以,我該如何做到這一點?..任何幫助將被讚賞。 Customer Name Now adapter如何根據AutoCompleteTextView中的另一個數組值顯示(突出顯示)值?

+0

http://stackoverflow.com/questions/13027261/autocompletetextview-search-part-of-word-instead-of - 全字/ 13027370#13027370檢查這個答案由我。 – Hardik4560

+0

您想根據客戶名稱或客戶地址進行搜索?寫你的代碼也.. – Venkat

+0

我想根據地址搜索.. –

回答

0

main.xml中

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello" 
    /> 
<AutoCompleteTextView android:id="@+id/myautocomplete" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:completionThreshold="1" 
/> 
</LinearLayout> 

AndroidAutoCompleteTextView.java

package com.AndroidAutoCompleteTextView; 

import android.app.Activity; 
import android.os.Bundle; 
import android.text.Editable; 
import android.text.TextWatcher; 
import android.widget.ArrayAdapter; 
import android.widget.AutoCompleteTextView; 

public class AndroidAutoCompleteTextView extends Activity implements TextWatcher{ 

AutoCompleteTextView myAutoComplete; 
String item[]={ 
    "January", "February", "March", "April", 
    "May", "June", "July", "August", 
    "September", "October", "November", "December" 
}; 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     myAutoComplete = (AutoCompleteTextView)findViewById(R.id.myautocomplete); 

     myAutoComplete.addTextChangedListener(this); 
     myAutoComplete.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, item)); 

    } 

@Override 
public void afterTextChanged(Editable arg0) { 
// TODO Auto-generated method stub 

} 

@Override 
public void beforeTextChanged(CharSequence s, int start, int count, 
    int after) { 
// TODO Auto-generated method stub 

} 

@Override 
public void onTextChanged(CharSequence s, int start, int before, int count) { 
// TODO Auto-generated method stub 

} 
} 
+0

我想顯示客戶名稱,當用戶在AutoCompleteTextView中輸入他們的地址.. –

相關問題