600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > android开发自定义选择器 创建自定义android选择器

android开发自定义选择器 创建自定义android选择器

时间:2019-07-10 20:32:26

相关推荐

android开发自定义选择器 创建自定义android选择器

我想下面的框架代码有助于为您的应用程序提供所需的一些灵活性.

/* Simple Dialog

Dialog dialog = new Dialog(this);

dialog.setTitle("Hello");

dialog.show();

*/

/* Inflating an layout as the Dialog

Dialog loginDialog = new Dialog(this);

View layout = LayoutInflater.from(this).inflate(R.layout.login, null);

loginDialog.setContentView(layout);

Button btn = (Button)(layout.findViewById(R.id.button1));

final EditText txt = (EditText) layout.findViewById(R.id.editText1);

btn.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {

// TODO Auto-generated method stub

//Toast.makeText(getApplicationContext(), txt.getText().toString(), Toast.LENGTH_SHORT).show();

txt.setText("Ahmedabad");

}

});

loginDialog.show();

/* ProgreessBar Dialog (you need to implement thread)

ProgressDialog dialog = new ProgressDialog(this);

dialog.setProgressStyle(2);

dialog.show();

*/

/* Alert Dialog to alert a mesage or an error or customize exception like Enter the field, etc.

AlertDialog dialog = new AlertDialog.Builder(this).create();

dialog.setMessage("Message");

dialog.setIcon(R.drawable.ic_launcher);

dialog.setTitle("Done");

dialog.show();

*/

/* ------------------- Binding array items into the spinner ---------------------------

sp = (Spinner)findViewById(R.id.spinner1);

String bloodgroups[]={

"A +ve","B +ve","O +ve","AB +ve","A -ve","B -ve","O -ve","AB -ve"

};

ArrayAdapter adapter=new ArrayAdapter(this,android.R.layout .simple_spinner_dropdown_item,bloodgroups);

sp.setAdapter(adapter);

*/

/* DatePicker Dialog Code: I have used a button whose click event bring datepicker dialog into focus

Button btnselDate = (Button)findViewById(R.id.btnseldate); // date select button

// ----------------------------- DATE PICKER DIALOG PROMPT ---------------------

btnselDate.setOnClickListener(new OnClickListener() {

public void onClick(View arg0) {

// TODO Auto-generated method stub

showDialog(1);

}

});

@Override

protected Dialog onCreateDialog(int id) {

DatePickerDialog dialog = new DatePickerDialog(this, new OnDateSetListener()

{

public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth)

{

((EditText)findViewById(R.id.txtdate)).setText(dayOfMonth + "/" + monthOfYear + "/" + year);

}

}, new GregorianCalendar().get(Calendar.YEAR), new GregorianCalendar().get(Calendar.MONTH), new GregorianCalendar().get(Calendar.DAY_OF_MONTH));

return dialog;

}

*/

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。