• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






♂小旭

 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理

2013年4月17日

Android中Activity间的跳转
摘要: 1、目的Activity要继承Activity:public class twoActivityextends Activity{...}2、myButton.setOnClickListener(new myButtonListener()) ;//按钮捆绑监听器class MyButtonListener implements OnClickListener{ //监听器,覆写OnClickListener //不传值时下面可以简写成:startActivity(new Intent(OneActivity.this, TwoActivity.class)); Intent inte... 阅读全文
posted @ 2013-04-17 11:24 ♂小旭 阅读(248) 评论(3) 推荐(0)
 
Android中的退出菜单
摘要: 在Activity.java中覆写onCreateOptionsMenu(Menu)回调函数public boolean onCreateOptionsMenu(Menu menu) { //(菜单组的名字,这项菜单(按钮)的ID,排序,按钮上的内容) 每个按钮对应一个 menu.add(0,1,1,title) return super.onCreateOptionsMenu(Menu);}再覆写onOptionsItemSeleted(MenuIntem)的回调函数public boolean onOptionsItemSeleted(menuIntem item) { //i... 阅读全文
posted @ 2013-04-17 11:16 ♂小旭 阅读(285) 评论(0) 推荐(0)
 
Android中一些布局文件实例
摘要: <LinearLayout //跟标签,布局方式采用线性布局 android:orientation="vertical" //标签方向垂直 android:layout_width="fill_parent" //控制宽度,父控件填满 android:layout_height="fill_parent" //控制高度, > <TextView //文本控件 android:id="@+id/myTextView" //设置控件id android:layout_width="fill 阅读全文
posted @ 2013-04-17 11:12 ♂小旭 阅读(157) 评论(0) 推荐(0)
 
Android中的控件设置信息总结
摘要: android:id //为控件指定IDandroid:text //指定控件显示的文字android:gravity //指定控件当中文字位置,居中"center"、居右(right)等android:textSize //文字大小"XXdp"android:background //背景颜色"#******"android:width //控件宽度,填满父控件(fill_parent)、刚好包含内容(wrap_content)android:height //控件高度android:weight //多个控件是表示所占比例andr 阅读全文
posted @ 2013-04-17 11:06 ♂小旭 阅读(239) 评论(0) 推荐(0)
 
Android中的SQLite数据库
摘要: //创建数据库,数据库名称为mydata.dbDatabaseHelper dbHelper = new DatabaseHelper(MyActivity.this, "mydata.db");SQLiteDatabase db = dbHelper.getReadableDatabase();p... 阅读全文
posted @ 2013-04-17 11:03 ♂小旭 阅读(6438) 评论(0) 推荐(0)
 
Android中的定时器
摘要: Timer mTimer = new Timer();mTimer.schedule(new TimerTask() { @Override public void run() { //要执行的操作 } }, 5*1000, 10*1000); //调用 schedule() 方法后,要等待5s才第一次执行 run() 方法,之后每隔10s执行一次 //停止定时器mTimer.cancel(); 本人发布的内容均为学习中用过的代码,上传主要为了方便以后的复习和为他人提供一些方便,一些代码没有上下文,新学的朋友有不... 阅读全文
posted @ 2013-04-17 10:39 ♂小旭 阅读(279) 评论(0) 推荐(0)
 
Android中弹出提示框
摘要: AlertDialog.Builder alertbBuilder=new AlertDialog.Builder(当前Activity.this);alertbBuilder.setTitle("提示").setMessage("确认退出?").setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //确定后... 阅读全文
posted @ 2013-04-17 10:36 ♂小旭 阅读(4146) 评论(0) 推荐(0)
 
Android中使用GPS时若未打开则跳至GPS设置界面
摘要: LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);//若GPS未打开,跳转到GPS设置页面if (!(locationManager.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER))){ //下面括号内的字符串也可以改为“gps” startActivity(new Intent("android.settings.LOCATION_SOURCE_SETTINGS&q 阅读全文
posted @ 2013-04-17 10:22 ♂小旭 阅读(1443) 评论(0) 推荐(0)
 
Android中GPS定位获取当前坐标
摘要: LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);//括号中的0,0分别表示每隔多长时间和每隔多长距离进行一次定位locationManager.requestL... 阅读全文
posted @ 2013-04-17 10:18 ♂小旭 阅读(882) 评论(0) 推荐(0)
 
Android中判断Service是否运行
摘要: if (isServiceStarted(MyCurrentActivity.this, "包名")){ txtStatus.setText("正在运行"); } else{ txtStatus.setText("未运行"); }public static boolean isServiceStarted(Context context,String PackageName){ boolean isStarted =false; try{ int intGetTastCounter = 1000; ActivityManager mA 阅读全文
posted @ 2013-04-17 10:07 ♂小旭 阅读(188) 评论(0) 推荐(0)
 
Android中Service的使用
摘要: //启动ServicestartService(new Intent(MyCurrentActivity.this, MyService.class));//停止ServicestopService(new Intent(MyCurrentActivity.this, MyService.class));@SuppressLint("SimpleDateFormat")public class MyGPSService extends Service { private String strLongitude; private String strLatitude; Tim 阅读全文
posted @ 2013-04-17 09:58 ♂小旭 阅读(312) 评论(0) 推荐(0)
 
Android中的日期时间显示
摘要: (一)SimpleDateFormat formatter = new SimpleDateFormat ("yyyy年MM月dd日 HH:mm:ss"); Date curDate = new Date(System.currentTimeMillis()); String time = formatter.format(curDate); (二)final Calendar c = Calendar.getInstance();String time = c.get(Calendar.YEAR)+"年"+c.get(Calendar.MONTH)+& 阅读全文
posted @ 2013-04-17 09:43 ♂小旭 阅读(443) 评论(0) 推荐(0)