- 博客(46)
- 收藏
- 关注
原创 GreenDao入门
在工程的build.gradle里面buildscript { repositories { google() jcenter() mavenCentral() // add repository } dependencies { classpath 'com.android.tools.buil
2017-11-30 16:55:33 545
原创 EventBus注册,取消注册,订阅,传值,黏性
先导入依赖compile 'org.greenrobot:eventbus:3.1.1'需要传值,写一个bean类public class MessageEvent { public boolean tag; public MessageEvent(boolean tag) { this.tag = tag; } public boo
2017-11-30 12:41:51 502
原创 Retrofit
MainActivity.javaimport android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.widget.Toast;import java.io.IOException;import java.util.HashMap;import java.util.Map;
2017-11-29 21:28:14 315
原创 通过反射获取字段,方法,注解
自定义一个注解//自己写的注解@interface表示注解 @Documented @Target(ElementType.METHOD)//添加在方法上的注解 @Retention(RetentionPolicy.RUNTIME)//在运行的时候public @interface Bwei { public String name() default "恩";
2017-11-29 12:58:26 822
原创 自定义注解,仿butterknife,找控件点击事件
activity_butter.xml里面写按钮<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.co
2017-11-29 12:32:04 433
原创 recyclerview点击条目事件
适配器里面的布局<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:padding="10dp" android:id="@+id/linear" android:layout
2017-11-23 13:11:43 331
原创 viewpager无限轮播,画小圆点,小圆点的布局
效果图:首先在布局中写viewpager控件activity_main.xml 下面linearlayout是小圆点的布局 <android.support.v4.view.ViewPager android:id="@+id/viewPager" android:layout_gravity="center_horizontal" andr...
2017-11-23 12:53:29 580
原创 MVP实现二级购物车
效果图 使用接口:http://120.27.23.105/product/getCarts?uid=100导入依赖 compile 'com.squareup.okhttp3:okhttp:3.9.0' compile 'com.google.code.gson:gson:2.8.2' compile 'com.android.support:recycler
2017-11-22 15:34:34 1335
原创 okhttp拦截器添加请求头
新建一个类UserAgentInterceptor实现Interceptorimport java.io.IOException;import okhttp3.Interceptor;import okhttp3.Request;import okhttp3.Response;/** * 添加请求头 */public class UserAgentIntercepter im
2017-11-22 11:43:03 4986
原创 购物车二级列表的实现,在一级列表基础上,bean类里再添加两个字段(请求本地json数据)
首先bean类里添加两个字段,,并且封装get set方法 //商品的选中 属性 private boolean check; //商家是否选中 private boolean shopCheck; //是否是第一个 如果isfirst 等于1 显示商户的名称, 否则隐藏商户的名称 private int isFirst = 2;Activity里
2017-11-20 21:25:19 393
原创 简单易用的轮播图控件Banner
导入依赖 compile 'com.github.bumptech.glide:glide:3.7.0' compile 'com.youth.banner:banner:1.4.10'清单文件中添加权限 activity_main中 <com.youth.banner.Banner android:id="@+id/banner"
2017-11-20 17:57:42 357
原创 使用BottomTabBar实现类似Fragment页面切换
依赖中导入 compile 'com.hjm:BottomTabBar:1.1.1' compile 'com.github.bumptech.glide:glide:3.7.0'activity_main里面的布局 ,引入bottomtabbar的布局<RelativeLayout xmlns:android="http://schemas.android.com/apk/re
2017-11-20 17:21:52 568
原创 android与JS交互,互相调用方法,跳转到网页
在main下面New - Folder - Assets Folder,在Assets下面新建一个js_android.html //这个方式是被java调用的 function androidCallJs(){ alert("java调用js弹窗");
2017-11-20 16:58:49 8080
原创 自定义弹窗对话框PopUpWindow
先写popupwindow.xml的布局,,一个输入框和一个按钮<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" andro
2017-11-20 15:37:02 433
原创 购物车一级列表的简单实现(访问接口数据)
导入依赖 compile 'com.squareup.okhttp3:okhttp:3.9.0' compile 'com.google.code.gson:gson:2.8.2' compile 'com.android.support:recyclerview-v7:25.0.0' compile 'com.nostra13.universalimageloader
2017-11-19 20:31:16 1361
原创 地图,定位,切换地图类型
在高德开放平台上下载地图的sdk和定位的sdk,解压jar包将.jar文件复制到libs下面,如果是3D地图,需要将在main下面新jniLibs,将.jar文件以外的都复制到jniLibs里面,并且右键add 添加依赖库清单文件中加入权限
2017-11-15 12:54:21 946
原创 极光推送自动集成与手动集成
在极光推送官网上注册账号并登录, 创建应用,应用名可以任意,但是包名必须和自己的项目包名一样,创建完成后会生成一个AppKey在 module 的 gradle中添加依赖和AndroidManifest的替换变量。手动集成apply plugin: 'com.android.application'android { compileSdkVersion 26
2017-11-14 18:00:28 2596 3
原创 属性动画代码及布局
布局中<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:l
2017-11-13 21:14:51 222
原创 点击图片,切换图片的显示,设置tag
imageView.setTag(1); gridLayoutManager = new GridLayoutManager(MainActivity.this,2); imageView.setOnClickListener(new View.OnClickListener() { @Override public
2017-11-13 19:02:38 266
原创 okhttp自定义拦截器,封装公共参数,get或post请求不同的拦截器
public class MyInterceptor implements Interceptor{ @Override public Response intercept(Chain chain) throws IOException { //使用自定義 公共參數,拼接在接口后面 Request request = chain.request(
2017-11-13 19:00:38 3666 2
原创 依赖的总结
1.极光推送的依赖 compile 'cn.jiguang.sdk:jpush:3.0.3' // 此处以JPush 3.0.3 版本为例。 compile 'cn.jiguang.sdk:jcore:1.1.1' // 此处以JCore 1.1.1 版本为例。 2. Tablelayout 依赖。 compile 'com.andr
2017-11-12 19:46:14 599
原创 调用OKhttp封装类请求网络数据适配到Recyclerview上拉下拉刷新
加入依赖compile 'com.liaoinstan.springview:library:1.3.0' compile 'com.android.support:recyclerview-v7:25.3.1'recyclerview布局的代码<LinearLayout xmlns:android="http://schemas.android.com/apk/res/andro
2017-11-12 19:14:12 577
原创 RadioButton加Fragment,点击按钮替换布局,注册Fragment
activity_main的布局<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout
2017-11-12 18:52:19 285
原创 MVP注册登录模块,结合数据库查询和添加数据
数据库的帮助类public class MyOpenHelper extends SQLiteOpenHelper{ public MyOpenHelper(Context context) { super(context, "day11.db", null, 1); } @Override public void onCreate(SQLit
2017-11-11 17:45:12 325
原创 OKHttp的封装类
导入okhttp依赖/** * Created by muhanxi on 17/11/10. * * * Okhttp 单例 范型的封装 */public class OkhttpUtils { private static OkhttpUtils okhttpUtils = null ; private OkhttpUtils(){ } pu
2017-11-11 17:35:53 300
原创 MVP操作RecyclerView多条目SpringView,OKHttp封装请求网络
build.gradle导入依赖apply plugin: 'com.android.application'android { compileSdkVersion 25 buildToolsVersion "25.0.1" defaultConfig { applicationId "com.example.lianxiday10_myp_rec
2017-11-10 21:21:08 386
原创 OkHttpClient,cache缓存,拦截器
导入okhttp依赖compile 'com.squareup.okhttp3:okhttp:3.9.0'MainActivity里面public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceSt
2017-11-09 21:12:46 1322
原创 第三方登录QQ完整版,授权登录
首先将Android_SDK_V3.3.0.lite下面的open_sdk_r5886_lite.jar粘贴到项目的libs下面,http://blog.csdn.net/sandyran/article/details/53319846<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2017-11-09 09:26:26 1790
原创 RecyclerView列表九宫格瀑布流,多条目,SpringView实现上拉下拉刷新
首先导入RecyclerView的依赖,SpringView的依赖compile 'com.android.support:recyclerview-v7:25.3.1'compile 'com.liaoinstan.springview:library:1.3.0'build.gradle里面的dependencies { compile fileTree(include:
2017-11-08 21:17:49 1568
原创 报错上传到bugly进行统计
https://bugly.qq.com/docs/user-guide/instruction-manual-android/?v=20170912151050集成SDK在Module的build.gradle文件中添加依赖和属性配置:dependencies { compile 'com.tencent.bugly:crashreport:latest.re
2017-11-08 17:54:57 470
原创 点击头像 侧滑菜单出现 仿QQ界面
点击头像 ,侧滑菜单显示 ,,给头像设置点击事件,判断当前侧面的闭合状态 如果是关闭的 就打开imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //如果没有打开侧面栏目 //gen是根布局 /
2017-11-06 17:44:22 1730
原创 XListView实现上拉加载下拉刷新,注意事项
使用XListview注意事项:首先将下载好的开源github代码中的view包里面的三个类,xlistview,xlistviewFooter,xlistviewHeaderlayout里面的xlistview_header,xlistview_footervalues下面的strings.xml里面的代码复制进来drawable下面的一张图片还要改那些类的R文件public cl
2017-11-06 17:33:30 237
原创 侧滑菜单中点击条目给主页面传值访问数据,主页面用farment替换布局
布局里 ,根布局是drawerlayout ,先写主背景的代码 再写侧面布局<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" androi
2017-11-06 17:25:47 394
原创 横向滑动菜单Tablayout,点击选项给下面的viewpager中的fragment传值
导入依赖 designcompile 'com.android.support:design:25.3.1' 布局里面<android.support.design.widget.TabLayout android:id="@+id/tab_layout" android:layout_width="match_parent" android:layout_
2017-11-06 17:00:32 736
原创 请求访问数据 展示在listview上 多条目根据奇偶数
public class PullListAdapter extends BaseAdapter{ int IMAGE = 0; int TEXT = 1; List list; Context context; public PullListAdapter(List list, Context context) { this.list =
2017-11-06 14:50:00 189
原创 横向滑动菜单Tablayout和viewpager小圆点结合滑动仿今日头条
使用Tablayout前需要添加依赖design.25.3.1xml version="1.0" encoding="utf-8"?>LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:la
2017-11-06 13:53:18 1293 1
原创 DrawerLayout侧滑菜单的布局,注意事项及代码
整体的布局里,先写主背景的布局,再写侧滑页面的布局<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/d
2017-11-06 13:25:30 362
原创 导航页面轮播图viewpager,滑到最后一页显示按钮
activity_second.xml布局里<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" andro
2017-11-06 13:16:22 1404
原创 SharedPrefrences存值取值,第二次进入页面跳转
public class MainActivity extends AppCompatActivity {private Handler handler = new Handler(){ @Override public void handleMessage(Message msg) { switch (msg.what){ case 0:
2017-11-06 13:07:17 604
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人