Android(安卓)按钮 弹出对话框
ackage com.example.helloworld;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn=(Button)this.findViewById(R.id.button1);
btn.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Dialog myDialog= new AlertDialog.Builder(MainActivity.this).setTitle("标题").setMessage("提示").create();
myDialog.show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
更多相关文章
- Android(安卓)代码片段---从相册或相机获取图片保存并处理
- Android(安卓)复用自制的控件(2)
- android 弹出带按钮的对话框
- Android标题栏(titlebar)显示进度条
- android 如何去掉状态栏和标题栏
- Android(安卓)TV自定义通用标题栏(组合控件)
- android Multiple markers at this line - The type java.lang.C
- 【Android学习笔记】AutoCompleteTextView(数组在代码中)
- Android(安卓)Studio自带模拟器读写SDcard不成功的解决办法