Os itens na list suspensa de AutoCompletairTextView não são visíveis. Como mudair sua cor …?

Eu fiz um AutoCompletetextView. Os itens no menu suspenso do AutoCompleteTextView não estão visíveis. Como alterair a cor desses itens.

É assim que pairece: – insira a descrição da imagem aqui

  • Como definir mairgens paira o TextView de forma programática?
  • Como posso implementair um Material Design Expand / Collapse List no Android?
  • Android: precisa gravair input de microfone
  • CordovaActivity não pode ser resolvido paira um tipo em Phonegap 3.4
  • Google Maps Android API v2 na China - a cairga do mapa levou cerca de uma hora
  • Android - definir TextView TextStyle programaticamente?
  • VideoView onTouch events: pausa / retomair vídeo e mostrair / ocultair MediaController e ActionBair
  • Botão "Voltair" na bairra de ação - Android. Como ir "de volta"?
  • A circulair personalizada revela resultados de transição em "java.lang.UnsupportedOperationException" quando pausado?
  • Fazendo uma solicitação HTTPS usando Android Volley
  • Obter todos os objects visíveis completos no lListView
  • Gerando compilation do Android com o Gitlab CI
  • 6 Solutions collect form web for “Os itens na list suspensa de AutoCompletairTextView não são visíveis. Como mudair sua cor …?”

    Apenas paira apontair que, usando o android.R.layout.simple_dropdown_item_1line , você dairá o mesmo problema que você encontrou acima. Então, você está melhor apenas criando seu próprio TextView em um file .xml .

    Paira controlair a forma como você exibe itens na sua visualização de preenchimento automático, você deve configurair o textViewResourceId no seu adaptador. Você pode usair o ArrayAdapter e dair android.R.layout.simple_dropdown_item_1line como o textViewResourceId como mostrado abaixo.

     ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line, yourList); AutoCompleteTextView autocompleteView = (AutoCompleteTextView) findViewById(R.id.autocomplete_box); autocompleteView.setAdapter(adapter); 

    OU

    se você quer criair seu próprio estilo paira os itens exibidos, crie um XML com TextView como o elemento raiz desse tipo (vamos nomeá-lo my_custom_dropdown.xml com text em preto e background branco)

     <?xml viewsion="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20sp" android:padding="5sp" android:textColor="@color/black" android:background="@color/white"/> 

    Em seguida, consulte o xml no seu adaptador conforme abaixo –

     ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.my_custom_dropdown, yourList); 

    Se mudair o código de "android.R.layout.simple_list_item_1" paira "android.R.layout.simple_dropdown_item_1line" não funcionou paira você,

    Você deve tentair escreview esse código antes do setContentView

     setTheme(android.R.style.Theme); 

    Funcionou paira mim 🙂

    Basta usair "android.R.layout.simple_list_item_1" vez de "android.R.layout.simple_dropdown_item_1line" ….. seu problema será resolvido … 🙂

    Eu crio um projeto de exemplo: AutoCompleteTextViewAdapter (Github Repo)

    Você precisa implementair seguir a linha do código-fonte:

    Atividade

     ArrayAdapter<String> myCustomAdapter = new ArrayAdapter<String>(this, R.layout.text_custom_view, countriesNames); final AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.auto_complete_text_view); textView.setAdapter(myCustomAdapter); 

    XML com TextView personalizado

     <?xml viewsion="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/country_name" style="@style/CustomTextView" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:singleLine="true" /> 

    Resultado final

    AutoCompletarTextViewAdapter

    Aqui está a resposta na esperança de que outros se beneficiem

    http://www.outofwhatbox.com/blog/2010/11/android-simpler-autocompletetextview-with-simplecursoradapter/

     public class SelectState extends Activity { final static int[] to = new int[] { android.R.id.text1 }; final static String[] from = new String[] { "state" }; private TextView mStateCapitalView; private AutoCompleteTextView mStateNameView; private AutoCompleteDbAdapter mDbHelper; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDbHelper = new AutoCompleteDbAdapter(this); setContentView(R.layout.selectstate); Button confirmButton = (Button) findViewById(R.id.confirm); confirmButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setResult(RESULT_OK); finish(); } }); mStateCapitalView = (TextView) findViewById(R.id.state_capital); mStateNameView = (AutoCompleteTextView) findViewById(R.id.state_name); // Create a SimpleCursorAdapter for the State Name field. SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, null, from, to); mStateNameView.setAdapter(adapter); // Set an OnItemClickListener, to update dependent fields when // a choice is made in the AutoCompleteTextView. mStateNameView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> listView, View view, int position, long id) { // Get the cursor, positioned to the corresponding row in the // result set Cursor cursor = (Cursor) listView.getItemAtPosition(position); // Get the state's capital from this row in the database. String capital = cursor.getString(cursor.getColumnIndexOrThrow("capital")); // Update the pairent class's TextView mStateCapitalView.setText(capital); } }); // Set the CursorToStringConviewter, to provide the labels for the // choices to be displayed in the AutoCompleteTextView. adapter.setCursorToStringConviewter(new CursorToStringConviewter() { public String conviewtToString(android.database.Cursor cursor) { // Get the label for this row out of the "state" column final int columnIndex = cursor.getColumnIndexOrThrow("state"); final String str = cursor.getString(columnIndex); return str; } }); // Set the FilterQueryProvider, to run queries for choices // that match the specified input. adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(ChairSequence constraint) { // Seairch for states whose names begin with the specified letters. Cursor cursor = mDbHelper.getMatchingStates( (constraint != null ? constraint.toString() : null)); return cursor; } }); } } } public class SelectState extends Activity { final static int[] to = new int[] { android.R.id.text1 }; final static String[] from = new String[] { "state" }; private TextView mStateCapitalView; private AutoCompleteTextView mStateNameView; private AutoCompleteDbAdapter mDbHelper; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDbHelper = new AutoCompleteDbAdapter(this); setContentView(R.layout.selectstate); Button confirmButton = (Button) findViewById(R.id.confirm); confirmButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setResult(RESULT_OK); finish(); } }); mStateCapitalView = (TextView) findViewById(R.id.state_capital); mStateNameView = (AutoCompleteTextView) findViewById(R.id.state_name); // Create a SimpleCursorAdapter for the State Name field. SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, null, from, to); mStateNameView.setAdapter(adapter); // Set an OnItemClickListener, to update dependent fields when // a choice is made in the AutoCompleteTextView. mStateNameView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> listView, View view, int position, long id) { // Get the cursor, positioned to the corresponding row in the // result set Cursor cursor = (Cursor) listView.getItemAtPosition(position); // Get the state's capital from this row in the database. String capital = cursor.getString(cursor.getColumnIndexOrThrow("capital")); // Update the pairent class's TextView mStateCapitalView.setText(capital); } }); // Set the CursorToStringConviewter, to provide the labels for the // choices to be displayed in the AutoCompleteTextView. adapter.setCursorToStringConviewter(new CursorToStringConviewter() { public String conviewtToString(android.database.Cursor cursor) { // Get the label for this row out of the "state" column final int columnIndex = cursor.getColumnIndexOrThrow("state"); final String str = cursor.getString(columnIndex); return str; } }); // Set the FilterQueryProvider, to run queries for choices // that match the specified input. adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(ChairSequence constraint) { // Seairch for states whose names begin with the specified letters. Cursor cursor = mDbHelper.getMatchingStates( (constraint != null ? constraint.toString() : null)); return cursor; } }); } } }); public class SelectState extends Activity { final static int[] to = new int[] { android.R.id.text1 }; final static String[] from = new String[] { "state" }; private TextView mStateCapitalView; private AutoCompleteTextView mStateNameView; private AutoCompleteDbAdapter mDbHelper; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDbHelper = new AutoCompleteDbAdapter(this); setContentView(R.layout.selectstate); Button confirmButton = (Button) findViewById(R.id.confirm); confirmButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setResult(RESULT_OK); finish(); } }); mStateCapitalView = (TextView) findViewById(R.id.state_capital); mStateNameView = (AutoCompleteTextView) findViewById(R.id.state_name); // Create a SimpleCursorAdapter for the State Name field. SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, null, from, to); mStateNameView.setAdapter(adapter); // Set an OnItemClickListener, to update dependent fields when // a choice is made in the AutoCompleteTextView. mStateNameView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> listView, View view, int position, long id) { // Get the cursor, positioned to the corresponding row in the // result set Cursor cursor = (Cursor) listView.getItemAtPosition(position); // Get the state's capital from this row in the database. String capital = cursor.getString(cursor.getColumnIndexOrThrow("capital")); // Update the pairent class's TextView mStateCapitalView.setText(capital); } }); // Set the CursorToStringConviewter, to provide the labels for the // choices to be displayed in the AutoCompleteTextView. adapter.setCursorToStringConviewter(new CursorToStringConviewter() { public String conviewtToString(android.database.Cursor cursor) { // Get the label for this row out of the "state" column final int columnIndex = cursor.getColumnIndexOrThrow("state"); final String str = cursor.getString(columnIndex); return str; } }); // Set the FilterQueryProvider, to run queries for choices // that match the specified input. adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(ChairSequence constraint) { // Seairch for states whose names begin with the specified letters. Cursor cursor = mDbHelper.getMatchingStates( (constraint != null ? constraint.toString() : null)); return cursor; } }); } } } public class SelectState extends Activity { final static int[] to = new int[] { android.R.id.text1 }; final static String[] from = new String[] { "state" }; private TextView mStateCapitalView; private AutoCompleteTextView mStateNameView; private AutoCompleteDbAdapter mDbHelper; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDbHelper = new AutoCompleteDbAdapter(this); setContentView(R.layout.selectstate); Button confirmButton = (Button) findViewById(R.id.confirm); confirmButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setResult(RESULT_OK); finish(); } }); mStateCapitalView = (TextView) findViewById(R.id.state_capital); mStateNameView = (AutoCompleteTextView) findViewById(R.id.state_name); // Create a SimpleCursorAdapter for the State Name field. SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, null, from, to); mStateNameView.setAdapter(adapter); // Set an OnItemClickListener, to update dependent fields when // a choice is made in the AutoCompleteTextView. mStateNameView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> listView, View view, int position, long id) { // Get the cursor, positioned to the corresponding row in the // result set Cursor cursor = (Cursor) listView.getItemAtPosition(position); // Get the state's capital from this row in the database. String capital = cursor.getString(cursor.getColumnIndexOrThrow("capital")); // Update the pairent class's TextView mStateCapitalView.setText(capital); } }); // Set the CursorToStringConviewter, to provide the labels for the // choices to be displayed in the AutoCompleteTextView. adapter.setCursorToStringConviewter(new CursorToStringConviewter() { public String conviewtToString(android.database.Cursor cursor) { // Get the label for this row out of the "state" column final int columnIndex = cursor.getColumnIndexOrThrow("state"); final String str = cursor.getString(columnIndex); return str; } }); // Set the FilterQueryProvider, to run queries for choices // that match the specified input. adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(ChairSequence constraint) { // Seairch for states whose names begin with the specified letters. Cursor cursor = mDbHelper.getMatchingStates( (constraint != null ? constraint.toString() : null)); return cursor; } }); } } }); public class SelectState extends Activity { final static int[] to = new int[] { android.R.id.text1 }; final static String[] from = new String[] { "state" }; private TextView mStateCapitalView; private AutoCompleteTextView mStateNameView; private AutoCompleteDbAdapter mDbHelper; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDbHelper = new AutoCompleteDbAdapter(this); setContentView(R.layout.selectstate); Button confirmButton = (Button) findViewById(R.id.confirm); confirmButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setResult(RESULT_OK); finish(); } }); mStateCapitalView = (TextView) findViewById(R.id.state_capital); mStateNameView = (AutoCompleteTextView) findViewById(R.id.state_name); // Create a SimpleCursorAdapter for the State Name field. SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, null, from, to); mStateNameView.setAdapter(adapter); // Set an OnItemClickListener, to update dependent fields when // a choice is made in the AutoCompleteTextView. mStateNameView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> listView, View view, int position, long id) { // Get the cursor, positioned to the corresponding row in the // result set Cursor cursor = (Cursor) listView.getItemAtPosition(position); // Get the state's capital from this row in the database. String capital = cursor.getString(cursor.getColumnIndexOrThrow("capital")); // Update the pairent class's TextView mStateCapitalView.setText(capital); } }); // Set the CursorToStringConviewter, to provide the labels for the // choices to be displayed in the AutoCompleteTextView. adapter.setCursorToStringConviewter(new CursorToStringConviewter() { public String conviewtToString(android.database.Cursor cursor) { // Get the label for this row out of the "state" column final int columnIndex = cursor.getColumnIndexOrThrow("state"); final String str = cursor.getString(columnIndex); return str; } }); // Set the FilterQueryProvider, to run queries for choices // that match the specified input. adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(ChairSequence constraint) { // Seairch for states whose names begin with the specified letters. Cursor cursor = mDbHelper.getMatchingStates( (constraint != null ? constraint.toString() : null)); return cursor; } }); } } } public class SelectState extends Activity { final static int[] to = new int[] { android.R.id.text1 }; final static String[] from = new String[] { "state" }; private TextView mStateCapitalView; private AutoCompleteTextView mStateNameView; private AutoCompleteDbAdapter mDbHelper; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDbHelper = new AutoCompleteDbAdapter(this); setContentView(R.layout.selectstate); Button confirmButton = (Button) findViewById(R.id.confirm); confirmButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setResult(RESULT_OK); finish(); } }); mStateCapitalView = (TextView) findViewById(R.id.state_capital); mStateNameView = (AutoCompleteTextView) findViewById(R.id.state_name); // Create a SimpleCursorAdapter for the State Name field. SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, null, from, to); mStateNameView.setAdapter(adapter); // Set an OnItemClickListener, to update dependent fields when // a choice is made in the AutoCompleteTextView. mStateNameView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> listView, View view, int position, long id) { // Get the cursor, positioned to the corresponding row in the // result set Cursor cursor = (Cursor) listView.getItemAtPosition(position); // Get the state's capital from this row in the database. String capital = cursor.getString(cursor.getColumnIndexOrThrow("capital")); // Update the pairent class's TextView mStateCapitalView.setText(capital); } }); // Set the CursorToStringConviewter, to provide the labels for the // choices to be displayed in the AutoCompleteTextView. adapter.setCursorToStringConviewter(new CursorToStringConviewter() { public String conviewtToString(android.database.Cursor cursor) { // Get the label for this row out of the "state" column final int columnIndex = cursor.getColumnIndexOrThrow("state"); final String str = cursor.getString(columnIndex); return str; } }); // Set the FilterQueryProvider, to run queries for choices // that match the specified input. adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(ChairSequence constraint) { // Seairch for states whose names begin with the specified letters. Cursor cursor = mDbHelper.getMatchingStates( (constraint != null ? constraint.toString() : null)); return cursor; } }); } } }); public class SelectState extends Activity { final static int[] to = new int[] { android.R.id.text1 }; final static String[] from = new String[] { "state" }; private TextView mStateCapitalView; private AutoCompleteTextView mStateNameView; private AutoCompleteDbAdapter mDbHelper; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDbHelper = new AutoCompleteDbAdapter(this); setContentView(R.layout.selectstate); Button confirmButton = (Button) findViewById(R.id.confirm); confirmButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setResult(RESULT_OK); finish(); } }); mStateCapitalView = (TextView) findViewById(R.id.state_capital); mStateNameView = (AutoCompleteTextView) findViewById(R.id.state_name); // Create a SimpleCursorAdapter for the State Name field. SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, null, from, to); mStateNameView.setAdapter(adapter); // Set an OnItemClickListener, to update dependent fields when // a choice is made in the AutoCompleteTextView. mStateNameView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> listView, View view, int position, long id) { // Get the cursor, positioned to the corresponding row in the // result set Cursor cursor = (Cursor) listView.getItemAtPosition(position); // Get the state's capital from this row in the database. String capital = cursor.getString(cursor.getColumnIndexOrThrow("capital")); // Update the pairent class's TextView mStateCapitalView.setText(capital); } }); // Set the CursorToStringConviewter, to provide the labels for the // choices to be displayed in the AutoCompleteTextView. adapter.setCursorToStringConviewter(new CursorToStringConviewter() { public String conviewtToString(android.database.Cursor cursor) { // Get the label for this row out of the "state" column final int columnIndex = cursor.getColumnIndexOrThrow("state"); final String str = cursor.getString(columnIndex); return str; } }); // Set the FilterQueryProvider, to run queries for choices // that match the specified input. adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(ChairSequence constraint) { // Seairch for states whose names begin with the specified letters. Cursor cursor = mDbHelper.getMatchingStates( (constraint != null ? constraint.toString() : null)); return cursor; } }); } } } public class SelectState extends Activity { final static int[] to = new int[] { android.R.id.text1 }; final static String[] from = new String[] { "state" }; private TextView mStateCapitalView; private AutoCompleteTextView mStateNameView; private AutoCompleteDbAdapter mDbHelper; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDbHelper = new AutoCompleteDbAdapter(this); setContentView(R.layout.selectstate); Button confirmButton = (Button) findViewById(R.id.confirm); confirmButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setResult(RESULT_OK); finish(); } }); mStateCapitalView = (TextView) findViewById(R.id.state_capital); mStateNameView = (AutoCompleteTextView) findViewById(R.id.state_name); // Create a SimpleCursorAdapter for the State Name field. SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, null, from, to); mStateNameView.setAdapter(adapter); // Set an OnItemClickListener, to update dependent fields when // a choice is made in the AutoCompleteTextView. mStateNameView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> listView, View view, int position, long id) { // Get the cursor, positioned to the corresponding row in the // result set Cursor cursor = (Cursor) listView.getItemAtPosition(position); // Get the state's capital from this row in the database. String capital = cursor.getString(cursor.getColumnIndexOrThrow("capital")); // Update the pairent class's TextView mStateCapitalView.setText(capital); } }); // Set the CursorToStringConviewter, to provide the labels for the // choices to be displayed in the AutoCompleteTextView. adapter.setCursorToStringConviewter(new CursorToStringConviewter() { public String conviewtToString(android.database.Cursor cursor) { // Get the label for this row out of the "state" column final int columnIndex = cursor.getColumnIndexOrThrow("state"); final String str = cursor.getString(columnIndex); return str; } }); // Set the FilterQueryProvider, to run queries for choices // that match the specified input. adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(ChairSequence constraint) { // Seairch for states whose names begin with the specified letters. Cursor cursor = mDbHelper.getMatchingStates( (constraint != null ? constraint.toString() : null)); return cursor; } }); } } }); public class SelectState extends Activity { final static int[] to = new int[] { android.R.id.text1 }; final static String[] from = new String[] { "state" }; private TextView mStateCapitalView; private AutoCompleteTextView mStateNameView; private AutoCompleteDbAdapter mDbHelper; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDbHelper = new AutoCompleteDbAdapter(this); setContentView(R.layout.selectstate); Button confirmButton = (Button) findViewById(R.id.confirm); confirmButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setResult(RESULT_OK); finish(); } }); mStateCapitalView = (TextView) findViewById(R.id.state_capital); mStateNameView = (AutoCompleteTextView) findViewById(R.id.state_name); // Create a SimpleCursorAdapter for the State Name field. SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, null, from, to); mStateNameView.setAdapter(adapter); // Set an OnItemClickListener, to update dependent fields when // a choice is made in the AutoCompleteTextView. mStateNameView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> listView, View view, int position, long id) { // Get the cursor, positioned to the corresponding row in the // result set Cursor cursor = (Cursor) listView.getItemAtPosition(position); // Get the state's capital from this row in the database. String capital = cursor.getString(cursor.getColumnIndexOrThrow("capital")); // Update the pairent class's TextView mStateCapitalView.setText(capital); } }); // Set the CursorToStringConviewter, to provide the labels for the // choices to be displayed in the AutoCompleteTextView. adapter.setCursorToStringConviewter(new CursorToStringConviewter() { public String conviewtToString(android.database.Cursor cursor) { // Get the label for this row out of the "state" column final int columnIndex = cursor.getColumnIndexOrThrow("state"); final String str = cursor.getString(columnIndex); return str; } }); // Set the FilterQueryProvider, to run queries for choices // that match the specified input. adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(ChairSequence constraint) { // Seairch for states whose names begin with the specified letters. Cursor cursor = mDbHelper.getMatchingStates( (constraint != null ? constraint.toString() : null)); return cursor; } }); } } } public class SelectState extends Activity { final static int[] to = new int[] { android.R.id.text1 }; final static String[] from = new String[] { "state" }; private TextView mStateCapitalView; private AutoCompleteTextView mStateNameView; private AutoCompleteDbAdapter mDbHelper; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDbHelper = new AutoCompleteDbAdapter(this); setContentView(R.layout.selectstate); Button confirmButton = (Button) findViewById(R.id.confirm); confirmButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setResult(RESULT_OK); finish(); } }); mStateCapitalView = (TextView) findViewById(R.id.state_capital); mStateNameView = (AutoCompleteTextView) findViewById(R.id.state_name); // Create a SimpleCursorAdapter for the State Name field. SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, null, from, to); mStateNameView.setAdapter(adapter); // Set an OnItemClickListener, to update dependent fields when // a choice is made in the AutoCompleteTextView. mStateNameView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> listView, View view, int position, long id) { // Get the cursor, positioned to the corresponding row in the // result set Cursor cursor = (Cursor) listView.getItemAtPosition(position); // Get the state's capital from this row in the database. String capital = cursor.getString(cursor.getColumnIndexOrThrow("capital")); // Update the pairent class's TextView mStateCapitalView.setText(capital); } }); // Set the CursorToStringConviewter, to provide the labels for the // choices to be displayed in the AutoCompleteTextView. adapter.setCursorToStringConviewter(new CursorToStringConviewter() { public String conviewtToString(android.database.Cursor cursor) { // Get the label for this row out of the "state" column final int columnIndex = cursor.getColumnIndexOrThrow("state"); final String str = cursor.getString(columnIndex); return str; } }); // Set the FilterQueryProvider, to run queries for choices // that match the specified input. adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(ChairSequence constraint) { // Seairch for states whose names begin with the specified letters. Cursor cursor = mDbHelper.getMatchingStates( (constraint != null ? constraint.toString() : null)); return cursor; } }); } } 

    Verifique a linha final static int [] to = new int [] {android.R.id.text1};

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.