android的AutoCompleteTextView
MainActivity的代码:
[java]
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class MainActivity extends Activity {
final String[] tips=new String[]{"hanhan","hanhan313","hanahn98","hanhan758"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//获取自动提示控件
AutoCompleteTextView actv=(AutoCompleteTextView)findViewById(R.id.actv);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.易做图_list_item_1,tips);
//设置数据适配器
actv.setAdapter(adapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
activity_main.xml的配置代码:
[html]
<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" >
<AutoCompleteTextView www.zzzyk.com
android:id="@+id/actv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#0000ff"
/>
</RelativeLayout>
补充:移动开发 , Android ,