上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页
摘要: 1、依赖:在app/build.gradle文件中的depenencies{compile 'org.litepal.android:core:1.3.2'} 2、配置litePal.xml:右击app/src/main-->New-->Directory,创建一个assets目录,在assets下 阅读全文
posted @ 2017-02-16 16:48 yl007 阅读(914) 评论(0) 推荐(0) 编辑
摘要: 动态注册广播接收器 1、创建一个Receiver继承BroadcastReceiver,并重写onReceiver() 2、在Activity的OnCreate()中添加广播接收器想要接收的action 3、注册广播接收器,调用registerReceiver(Receiver实例,intentFi 阅读全文
posted @ 2017-02-16 16:11 yl007 阅读(842) 评论(0) 推荐(0) 编辑
摘要: 简单用法: 1.新建布局、新建fragment类 2.在activity_main.xml中添加fragment 动态加载fragment: 1.创建待加载的fragment实例 2.获取FragmentManager,通过getSupportFragmentManager():FragmentMa 阅读全文
posted @ 2017-02-15 16:00 yl007 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 1.首先在build.gradle中添加依赖库 compile 'com.android.support:recyclerview-v7:24.2.1' 2.修改activity_main.xml 3.类似ListView,新建一个适配器FruitAdapter,定义一个ViewHolder内部类, 阅读全文
posted @ 2017-02-15 14:10 yl007 阅读(823) 评论(0) 推荐(0) 编辑
摘要: ListView使用需要:data、控件、adapter 自定义adapter: 继承adapter并重写getView() 重用convertView,提升ListView效率 在getView方法中添加代码:(如果convertView为空则动态加载布局,否则重用convertView) 利用V 阅读全文
posted @ 2017-02-13 23:25 yl007 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 引入控件: 1、在activity_xml中添加<include layout="@layout/title"> 2、隐藏自带标题栏:在onCreate()中添加代码:ActionBar actionBar = getSupportActionBar(); if(actionBar != null) 阅读全文
posted @ 2017-02-13 22:12 yl007 阅读(75) 评论(0) 推荐(0) 编辑
摘要: 随时随地退出程序 新建一个结合类对所有活动进行管理。 启动活动技巧 在SecondActivity中添加一个actionStrat() 启动SecondActivity 杀死整个App 双击退出程序两个方法: 1)定义一个变量,来标识是否退出 2)保存点击时间: 阅读全文
posted @ 2017-02-09 11:40 yl007 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 显示Intent 通过构造函数的重载,创建Intent对象,并用startActivity()启动目标活动。 目标活动需要在AndroidManifest.xml中注册 隐式Intent 指定了一系列的action和category。 1.在AndroidManifest.xml中添加如下代码: 只 阅读全文
posted @ 2017-02-09 10:46 yl007 阅读(395) 评论(0) 推荐(0) 编辑
摘要: 1.右击res-->New-->Directory输入文件名menu,在此文件夹下新建main菜单文件:右击menu-->New-->Menu resource file 2.在main.xml中添加如下代码: 3.活动中重写OnCreateOptionsMenu()方法 4.响应item点击事件 阅读全文
posted @ 2017-02-09 09:51 yl007 阅读(683) 评论(0) 推荐(0) 编辑
摘要: 全局获取Context 定制一个自己的Application类,管理程序内一些全局的状态信息。 步骤:1、创建一个类继承Application类 2、重写onCreate(),通过调用getApplicationContext()得到一个应用程序级别的Context 3、调用静态的getContex 阅读全文
posted @ 2016-12-08 15:10 yl007 阅读(98) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页