Android AlertDialog显示时间
复制代码
-----------------------------------------------------------------
Android创建项目时所填写的名称和Android程序之间的关系
在创建Android项目时(Eclipse+AndroidSDK),需要填写的信息很多,如下图所示
Android项目创建完成之后:
在Android模拟器中:
在Android程序列表中显示的名称:
总结:
1.Project name:仅仅在Eclipse中使用
2.Application name:在Android程序列表和Android程序运行时,显示的是“Application name”
3.Package name:源代码包的位置
4.Create Activity:选择的化会创建一个默认的activity
- import java.text.SimpleDateFormat;
- import java.util.Date;
-
- import android.app.Activity;
- import android.app.AlertDialog;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
-
- public class main extends Activity implements OnClickListener {
- /** Called when the activity is first created. */
- private Button btnshowDate;
- private Button btnshowTime;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- btnshowDate = (Button) findViewById(R.id.btnShowDate);
- btnshowTime = (Button) findViewById(R.id.btnShowTime);
-
- btnshowDate.setOnClickListener(this);
- btnshowTime.setOnClickListener(this);
- }
-
- @Override
- public void onClick(View v) {
- // TODO Auto-generated method stub
- switch (v.getId()) {
- case R.id.btnShowDate: {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- showDialog("当前日期", sdf.format(new Date()));
- break;
- }
- case R.id.btnShowTime: {
- SimpleDateFormat sdf = new SimpleDateFormat("HH:mm;ss");
- showDialog("当前时间", sdf.format(new Date()));
- break;
- }
- }
- }
-
- private void showDialog(String title, String msg) {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setIcon(android.R.drawable.ic_dialog_info);
- builder.setTitle(title);
- builder.setMessage(msg);
- builder.setPositiveButton("确定", null);
- builder.create().show();
- Intent intent;
- }
- }
Android创建项目时所填写的名称和Android程序之间的关系
在创建Android项目时(Eclipse+AndroidSDK),需要填写的信息很多,如下图所示
![](http://www.eoeandroid.com/data/attachment/forum/201210/16/150154as4aax0abyrahcy5.jpg)
Android项目创建完成之后:
![](http://www.eoeandroid.com/data/attachment/forum/201210/16/150220tos7btyjmkqs6js6.jpg)
在Android模拟器中:
![](http://www.eoeandroid.com/data/attachment/forum/201210/16/150255p9e51kzppppg756z.jpg)
在Android程序列表中显示的名称:
![](http://www.eoeandroid.com/data/attachment/forum/201210/16/150325e77wc777qw69ewqq.jpg)
总结:
1.Project name:仅仅在Eclipse中使用
2.Application name:在Android程序列表和Android程序运行时,显示的是“Application name”
3.Package name:源代码包的位置
4.Create Activity:选择的化会创建一个默认的activity