Android学习笔记(1)

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样式
Android学习笔记(1)
ProgressDialog样式
Android学习笔记(1)

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编程权威指南》

上一篇:AsyncTask的进度对话 – Android


下一篇:android – 如何在不模糊背景窗口的情况下创建ProgressDialog