when the user click the editText Field I need to show spinner(dynamic) from that user select any of the item i need to set the Text for Edit text .How to do this?
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();
}
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With