private void showDialog(String title, String text) { final Dialog dia = new Dialog(this); dia.setContentView(R.layout.msgdialog); dia.setTitle(title); Button okbutton = (Button) dia.findViewById(R.id.okbutton); TextView textField = (TextView) dia.findViewById(R.id.msg); textField.setTextSize(12f); textField.setBackgroundColor(Color.BLACK); textField.setTextColor(Color.WHITE); textField.setText(text); okbutton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { dia.dismiss(); } }); dia.show(); }
上面的是主要是想逻辑,超简单。