在输入框中输入我们想要输入的信息就会出现其他与其相关的提示信息,这种效果在Android中是用AutoCompleteTextView实现的。

<AutoCompleteTextView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/autotext" />
public class MainActivity extends Activity {
private AutoCompleteTextView autotext;
private ArrayAdapter<String> arrayAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test);
autotext =(AutoCompleteTextView) findViewById(R.id.autotext);
String [] arr={"aa","aab","aac"};
arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,arr);
autotext.setAdapter(arrayAdapter);
}
}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。