2011-06-14 3 views

답변

0

나는 이미 주어진 타격 코드를 읽어 보시기 바랍니다 했어요. 나는 그것이 당신에게 매우 유용하기를 바랍니다.

public static String[] COUNTRIES = { "Afganistan", "Algeria", "Albania", 
     "Angola", "Anguilla", "Antigua and\nBarbuda", "Argentina", 
     "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", 
     "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus" }; 

@Override 
public void onCreate(Bundle icicle) { 
    super.onCreate(icicle); 
    setContentView(R.layout.main); 

    AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.txtCountry); 

    countryNames = COUNTRIES; // this is where you would fire a loader 
    // and set the adapter when you get a result, so the following would be in a callback 
    ed.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, countryNames)); 
} 
1

자사의 자동 완성 텍스트 뷰

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

얼마나 유감! 이 링크에 액세스 할 수 없습니다. 차단되었을 수 있습니다. – David

관련 문제