android笔记之autoCompleteTextView

package com.example.autocomplete;



import android.os.Bundle;
import android.app.Activity;
import android.graphics.Color;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		AutoCompleteTextView auto=(AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
		String[] arr={"a","abc","ab","acd"};
		ArrayAdapter adapter=new ArrayAdapter(this,android.R.layout.simple_dropdown_item_1line, arr);
		auto.setAdapter(adapter);
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

}

Activity文件的代码如上所示。

布局文件如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" 
    >

     <AutoCompleteTextView 
        android:id="@+id/autoCompleteTextView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:completionHint="请选择你喜欢的歌曲"
        android:completionThreshold="1"
        android:dropDownHorizontalOffset="20dp"
              
        />

</RelativeLayout>
使用API10开发运行的时候,下方会出现提示的记录有四条,而且点击空白处的时候,会有相应的文字提示出现在文本框中,可是下面的自动补全提示中,竟然没有文字出现,实在是费解。

解决办法:

把  AndroidMainFest.xml中的android:theme="...."     删掉 即可



你可能感兴趣的:(android笔记之autoCompleteTextView)