AlertDialog and ProgressDialog
AlertDialog and ProgressDialog
简单代码:
AlertDialog.Builder dialog= new AlertDialog.Builder(MainActivity.this);
dialog.setTitle("!!!!!!!!");
dialog.setMessage("..........");
dialog.show();
ProgressDialog dialog= new ProgressDialog(MainActivity.this);
AlertDialog样式
ProgressDialog样式
AlertDialog需要(.Builder)来创建实例,而ProgressDialog则不用;
记得先设监听器!!!!!!
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private Button mButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mButton=(Button)findViewById(R.id.button2);
mButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder dialog= new AlertDialog.Builder(MainActivity.this);
dialog.setTitle("!!!!!!!!");
dialog.setMessage("..........");
dialog.show();
} });
}
@Override
public void onClick(View view) {
}
}
新手推荐:
[1]: 《第一行代码》
[2]: 《Android编程权威指南》