- 博客(26)
- 收藏
- 关注
原创 EventBus 简单实用 黏性事件
导入依赖implementation 'org.greenrobot:eventbus:3.0.0' 这种是黏性事件EventBus.getDefault().postSticky(token);//token是我需要传递的参数接受页面需要注册与反注册EventBus.getDefault().register(this);//注册接受的方法 因为是...
2019-08-15 17:22:46
169
转载 okhttp实现网络请求
ok依赖 implementation 'com.squareup.okhttp3:okhttp:3.6.0'implementation 'com.squareup.okio:okio:1.11.0'网络权限 <uses-permission android:name="android.permission.INTERNET"></uses-...
2019-06-17 21:00:25
226
原创 字符串转为时间戳日期格式
// 时间戳 final String dateToString = getDateToString(resultBeans.getReleaseTime()); myViewHolder.time.setText(dateToString);/*时间戳转换成字符窜*/ public String getDateToString...
2019-05-23 21:07:15
986
转载 WebView加载html网页
@Override public void getViewData(DetailBean detailBean) { DetailBean.ResultBean result = detailBean.getResult();// Toast.makeText(this, "" + result.toString(), Toast.LENGTH...
2019-04-07 11:52:00
1643
原创 自定义View组合控件搜索框搜索内容
自定义组合控件Button按钮点击事件 private void ininData(final Context context) { LayoutInflater.from(context).inflate(R.layout.search_layout, this); seek = findViewById(R.id.search_seek); ...
2019-04-07 08:18:53
298
原创 Android 二级购物车计算总价
二级商品适配器 myViewHolder.checkBox.setChecked(list.get(i).isChildCheck()); myViewHolder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { ...
2019-04-06 14:49:33
673
原创 Fragment懒加载
boolean isview; boolean isuser; public T persenter; @Override public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); isus...
2019-04-01 07:45:07
110
转载 Okhttp中添加请求头请求体
// 获取ok private static OkHttpClient okHttpClient; private static synchronized OkHttpClient getOkHttpClient() {// 拦截器 HttpLoggingInterceptor interceptor = new HttpLoggin...
2019-03-25 08:11:41
5392
原创 Green dao有网
if (page == 1) {// 创建新集合 list = new ArrayList<>();// 清空 dataBeanDao.deleteAll(); for (int i = 0; i < data.size(); i++) { ...
2019-03-18 08:05:47
114
原创 Green dao判断是否有网加载数据
dataBeanDao = MyApplication.getInstance().getDaoSession().getDataBeanDao();// 有网加载数据 if (NetWorkUtils.isNetWoekConnect(MainActivity.this)) { presenter.show(page); ...
2019-03-18 08:04:40
155
转载 Green dao 的application写法
Green dao 的application写法public class MyApplication extends Application { public static MyApplication instance; private DaoMaster.DevOpenHelper helper; private SQLiteDatabase db; ...
2019-03-18 07:52:15
122
转载 Android模拟购物车加减器
public class ZView extends LinearLayout implements View.OnClickListener { private int number = 1; private EditText num_goods; public ZView(Context context) { super(context); ...
2019-03-08 11:32:03
222
转载 FlyBanner简单的轮播效果
代码// 轮播 private void initLun() { List<String> list = new ArrayList<String>(); list.add("http://172.17.8.100/images/small/banner/cj.png"); list.add("http...
2019-03-08 10:31:32
193
原创 Android调用js简单方法
// 初始化 web_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { WebSettings settings = webView.getSett...
2019-03-08 09:46:11
948
转载 RecyclerView.Adapter多条目适配器
package com.bw.week2_04.adapter;import android.content.Context;import android.support.annotation.NonNull;import android.support.v7.widget.RecyclerView;import android.view.LayoutInflater;import ...
2019-02-26 08:14:44
565
转载 OkHttp抽取类(单例模式)
package com.bw.week2_04.utils;import android.util.Log;import okhttp3.Call;import okhttp3.Callback;import okhttp3.Interceptor;import okhttp3.OkHttpClient;import okhttp3.Request;import okhttp3...
2019-02-25 19:32:52
773
原创 RecyclerView 原生解析 多条目展示
package com.example.week01_02.adapter;import android.content.Context;import android.support.annotation.NonNull;import android.support.v7.widget.RecyclerView;import android.view.LayoutInflater;i...
2019-02-18 08:19:46
160
原创 Viewpager的底部适配
@Override protected void initData() {// 默认选中第一个 radioGroup.check(R.id.main_button1); final ArrayList<Fragment> list = new ArrayList<Fragment>(); li...
2019-01-21 07:58:48
268
原创 引导页简单写法
引导页简单布局 <android.support.v4.view.ViewPager android:id="@+id/main_pager" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight...
2019-01-21 07:57:56
567
原创 Handler倒计时五秒(自动跳转)
public class MainActivity extends AppCompatActivity { private Button button; private int time = 5; @Override protected void onCreate(Bundle savedInstanceState) { super.onCre...
2019-01-20 20:01:06
629
原创 XListview展示优化后
package com.example.week2_04.frag;import android.os.AsyncTask;import android.os.Bundle;import android.os.Handler;import android.os.Message;import android.support.annotation.NonNull;import andr...
2019-01-07 13:34:48
98
转载 Asynctask请求接口
请求接口的路径 private String path = "http://api.expoon.com/AppNews/getNewsList/type/1/p/1"; Asynctask注册// 注册 MyAsynctask myAsynctask = new MyAsynctask(); myAsynctask.exe...
2019-01-04 15:05:37
323
原创 HttpConnection 获取接口的 Handler
Handler handler = new Handler(){ @Override public void handleMessage(Message msg) {// super.handleMessage(msg); if (msg.what ==0){ String ...
2018-12-30 11:42:39
189
原创 BroadcastReceiver广播监听
// 动态监听广播 private class MyBroadcastReceiver extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { boolean netWorkConnect = NetWorkUtils...
2018-12-30 11:39:30
279
原创 判断网络
public static boolean isNetWorkConnect(Context context){// 获取网络管理者、 ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); ...
2018-12-30 11:36:07
94
原创 注册动态监听
// ---------------------------------------------------------------------------// 注册监听 MyBroadcastReceiver myBroadcastReceiver = new MyBroadcastReceiver(); IntentFilter...
2018-12-30 11:35:50
202
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人