gpt4 book ai didi

android - 在 Android 中单击编辑文本时显示微调器?

转载 作者:太空宇宙 更新时间:2023-11-03 11:53:54 24 4
gpt4 key购买 nike

当用户单击 editText 字段时,我需要显示来自该用户的微调器(动态),选择我需要为编辑文本设置文本的任何项目。如何执行此操作?

最佳答案

public class Main extends Activity implements OnClickListener{

TextView textview_countries;

private String[] countries_list={"Philippines","Japan","Australia"};
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

textview_countries=(TextView) findViewById(R.id.txtview_countries);
textview_countries.setInputType(InputType.TYPE_NULL); //To hide the softkeyboard


final ArrayAdapter<String> spinner_countries = new ArrayAdapter<String>(Main.this,android.R.layout.simple_spinner_dropdown_item, countries_list);

textview_countries.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
new AlertDialog.Builder(Main.this)
.setTitle("Select Countries")
.setAdapter(spinner_countries, new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int which) {
textview_countries.setText(countries_list[which].toString());
dialog.dismiss();
}
}).create().show();
}
});
}

关于android - 在 Android 中单击编辑文本时显示微调器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4266075/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com