• Fragment相关→FragmentUtils.javaDemo

    addFragment              : 新增fragment
    removeFragment : 移除fragment
    replaceFragment : 替换fragment
    popFragment : 出栈fragment
    popToFragment : 出栈到指定fragment
    popAddFragment : 先出栈后新增fragment
    hideFragment : 隐藏fragment
    showFragment : 显示fragment
    hideShowFragment : 先隐藏后显示fragment
    getLastAddFragment : 获取最后加入的fragment
    getLastAddFragmentInStack: 获取栈中最后加入的fragment
    getTopShowFragment : 获取顶层可见fragment
    getTopShowFragmentInStack: 获取栈中顶层可见fragment
    findFragment : 查找fragment
    getPreFragment : 获取目标fragment的前一个fragment
    getFragments : 获取同级别的fragment
    getAllFragments : 获取所有fragment
    getAllFragmentsInStack : 获取栈中所有fragment
    setBackgroundColor : 设置背景色
    setBackgroundResource : 设置背景资源
    setBackground : 设置背景

具体路线

import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.ColorInt;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; /**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2017/1/17
* desc : Fragment相关工具类
* </pre>
*/
public class FragmentUtils { private FragmentUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
} private static final int TYPE_ADD_FRAGMENT = 0x01 << 0;
private static final int TYPE_REMOVE_FRAGMENT = 0x01 << 1;
private static final int TYPE_REPLACE_FRAGMENT = 0x01 << 2;
private static final int TYPE_HIDE_FRAGMENT = 0x01 << 3;
private static final int TYPE_SHOW_FRAGMENT = 0x01 << 4;
private static final int TYPE_HIDE_SHOW_FRAGMENT = 0x01 << 5;
private static final int TYPE_POP_ADD_FRAGMENT = 0x01 << 6; private static final String ARGS_ID = "args_id";
private static final String ARGS_IS_HIDE = "args_is_hide";
private static final String ARGS_IS_ADD_STACK = "args_is_add_stack"; /**
* 新增fragment
*
* @param fragmentManager fragment管理器
* @param containerId 布局Id
* @param fragment fragment
* @return fragment
*/
public static Fragment addFragment(@NonNull FragmentManager fragmentManager,
@NonNull Fragment fragment,
int containerId) {
return addFragment(fragmentManager, fragment, containerId, false);
} /**
* 新增fragment
*
* @param fragmentManager fragment管理器
* @param containerId 布局Id
* @param fragment fragment
* @param isHide 是否显示
* @return fragment
*/
public static Fragment addFragment(@NonNull FragmentManager fragmentManager,
@NonNull Fragment fragment,
int containerId,
boolean isHide) {
return addFragment(fragmentManager, fragment, containerId, isHide, false);
} /**
* 新增fragment
*
* @param fragmentManager fragment管理器
* @param containerId 布局Id
* @param fragment fragment
* @param isHide 是否显示
* @param isAddStack 是否入回退栈
* @return fragment
*/
public static Fragment addFragment(@NonNull FragmentManager fragmentManager,
@NonNull Fragment fragment,
int containerId,
boolean isHide,
boolean isAddStack) {
putArgs(fragment, new Args(containerId, isHide, isAddStack));
return operateFragment(fragmentManager, null, fragment, TYPE_ADD_FRAGMENT);
} /**
* 新增fragment
*
* @param fragmentManager fragment管理器
* @param containerId 布局Id
* @param fragment fragment
* @param isAddStack 是否入回退栈
* @param sharedElement 共享元素
* @return fragment
*/
public static Fragment addFragment(@NonNull FragmentManager fragmentManager,
@NonNull Fragment fragment,
int containerId,
boolean isAddStack,
SharedElement... sharedElement) {
putArgs(fragment, new Args(containerId, false, isAddStack));
return operateFragment(fragmentManager, null, fragment, TYPE_ADD_FRAGMENT, sharedElement);
} /**
* 移除fragment
*
* @param fragment fragment
* @return fragment
*/
public static Fragment removeFragment(@NonNull Fragment fragment) {
return operateFragment(fragment.getFragmentManager(), null, fragment, TYPE_REMOVE_FRAGMENT);
} /**
* 替换fragment
*
* @param srcFragment 源fragment
* @param destFragment 目标fragment
* @param isAddStack 是否入回退栈
* @return {@code null} 失败
*/
public static Fragment replaceFragment(@NonNull Fragment srcFragment,
@NonNull Fragment destFragment,
boolean isAddStack) {
if (srcFragment.getArguments() == null) return null;
int containerId = srcFragment.getArguments().getInt(ARGS_ID);
if (containerId == 0) return null;
return replaceFragment(srcFragment.getFragmentManager(), containerId, destFragment, isAddStack);
} /**
* 替换fragment
*
* @param fragmentManager fragment管理器
* @param containerId 布局Id
* @param fragment fragment
* @param isAddStack 是否入回退栈
* @return fragment
*/
public static Fragment replaceFragment(@NonNull FragmentManager fragmentManager,
int containerId,
@NonNull Fragment fragment,
boolean isAddStack) {
putArgs(fragment, new Args(containerId, false, isAddStack));
return operateFragment(fragmentManager, null, fragment, TYPE_REPLACE_FRAGMENT);
} /**
* 出栈fragment
*
* @param fragmentManager fragment管理器
* @return {@code true}: 出栈成功<br>{@code false}: 出栈失败
*/
public static boolean popFragment(@NonNull FragmentManager fragmentManager) {
return fragmentManager.popBackStackImmediate();
} /**
* 出栈到指定fragment
*
* @param fragmentManager fragment管理器
* @param fragmentClass Fragment类
* @param isIncludeSelf 是否包括Fragment类自己
* @return {@code true}: 出栈成功<br>{@code false}: 出栈失败
*/
public static boolean popToFragment(@NonNull FragmentManager fragmentManager,
Class<? extends Fragment> fragmentClass,
boolean isIncludeSelf) {
return fragmentManager.popBackStackImmediate(fragmentClass.getName(), isIncludeSelf ? FragmentManager.POP_BACK_STACK_INCLUSIVE : 0);
} /**
* 先出栈后新增fragment
*
* @param fragmentManager fragment管理器
* @param containerId 布局Id
* @param fragment fragment
* @param isAddStack 是否入回退栈
* @return fragment
*/
public static Fragment popAddFragment(@NonNull FragmentManager fragmentManager,
int containerId,
@NonNull Fragment fragment,
boolean isAddStack,
SharedElement... sharedElement) {
putArgs(fragment, new Args(containerId, false, isAddStack));
return operateFragment(fragmentManager, null, fragment, TYPE_POP_ADD_FRAGMENT, sharedElement);
} /**
* 先出栈后新增fragment
*
* @param fragmentManager fragment管理器
* @param containerId 布局Id
* @param fragment fragment
* @param isAddStack 是否入回退栈
* @return fragment
*/
public static Fragment popAddFragment(@NonNull FragmentManager fragmentManager,
int containerId,
@NonNull Fragment fragment,
boolean isAddStack) {
putArgs(fragment, new Args(containerId, false, isAddStack));
return operateFragment(fragmentManager, null, fragment, TYPE_POP_ADD_FRAGMENT);
} /**
* 隐藏fragment
*
* @param fragment fragment
*/
public static Fragment hideFragment(@NonNull Fragment fragment) {
Args args = getArgs(fragment);
if (args != null) {
putArgs(fragment, new Args(args.id, true, args.isAddStack));
}
return operateFragment(fragment.getFragmentManager(), null, fragment, TYPE_HIDE_FRAGMENT);
} /**
* 显示fragment
*
* @param fragment fragment
*/
public static Fragment showFragment(@NonNull Fragment fragment) {
Args args = getArgs(fragment);
if (args != null) {
putArgs(fragment, new Args(args.id, false, args.isAddStack));
}
return operateFragment(fragment.getFragmentManager(), null, fragment, TYPE_SHOW_FRAGMENT);
} /**
* 先隐藏后显示fragment
*
* @param hideFragment 需要hide的Fragment,如果为null则把栈中的fragment都隐藏
* @param showFragment 需要show的Fragment
*/
public static Fragment hideShowFragment(@NonNull Fragment hideFragment,
@NonNull Fragment showFragment) {
Args args = getArgs(hideFragment);
if (args != null) {
putArgs(hideFragment, new Args(args.id, true, args.isAddStack));
}
args = getArgs(showFragment);
if (args != null) {
putArgs(showFragment, new Args(args.id, false, args.isAddStack));
}
return operateFragment(showFragment.getFragmentManager(), hideFragment, showFragment, TYPE_HIDE_SHOW_FRAGMENT);
} /**
* 传参
*
* @param fragment fragment
* @param args 参数
*/
private static void putArgs(@NonNull Fragment fragment, Args args) {
Bundle bundle = fragment.getArguments();
if (bundle == null) {
bundle = new Bundle();
fragment.setArguments(bundle);
}
bundle.putInt(ARGS_ID, args.id);
bundle.putBoolean(ARGS_IS_HIDE, args.isHide);
bundle.putBoolean(ARGS_IS_ADD_STACK, args.isAddStack);
} /**
* 获取参数
*
* @param fragment fragment
*/
private static Args getArgs(@NonNull Fragment fragment) {
Bundle bundle = fragment.getArguments();
if (bundle == null || bundle.getInt(ARGS_ID) == 0) return null;
return new Args(bundle.getInt(ARGS_ID), bundle.getBoolean(ARGS_IS_HIDE), bundle.getBoolean(ARGS_IS_ADD_STACK));
} /**
* 操作fragment
*
* @param fragmentManager fragment管理器
* @param srcFragment 源fragment
* @param destFragment 目标fragment
* @param type 操作类型
* @param sharedElements 共享元素
* @return destFragment
*/
private static Fragment operateFragment(@NonNull FragmentManager fragmentManager,
Fragment srcFragment,
@NonNull Fragment destFragment,
int type,
SharedElement... sharedElements) {
if (srcFragment == destFragment) return null;
if (srcFragment != null && srcFragment.isRemoving()) {
LogUtils.e(srcFragment.getClass().getName() + " is isRemoving");
return null;
}
String name = destFragment.getClass().getName();
Bundle args = destFragment.getArguments(); FragmentTransaction ft = fragmentManager.beginTransaction();
if (sharedElements == null || sharedElements.length == 0) {
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
} else {
for (SharedElement element : sharedElements) {// 添加共享元素动画
ft.addSharedElement(element.sharedElement, element.name);
}
}
switch (type) {
case TYPE_ADD_FRAGMENT:
ft.add(args.getInt(ARGS_ID), destFragment, name);
if (args.getBoolean(ARGS_IS_HIDE)) ft.hide(destFragment);
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
break;
case TYPE_REMOVE_FRAGMENT:
ft.remove(destFragment);
break;
case TYPE_POP_ADD_FRAGMENT:
popFragment(fragmentManager);
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
ft.add(args.getInt(ARGS_ID), destFragment, name);
break;
case TYPE_HIDE_FRAGMENT:
ft.hide(destFragment);
break;
case TYPE_SHOW_FRAGMENT:
ft.show(destFragment);
break;
case TYPE_HIDE_SHOW_FRAGMENT:
ft.hide(srcFragment).show(destFragment);
break;
case TYPE_REPLACE_FRAGMENT:
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
ft.replace(args.getInt(ARGS_ID), destFragment, name);
break;
}
ft.commitAllowingStateLoss();
return destFragment;
} /**
* 获取最后加入的fragment
*
* @param fragmentManager fragment管理器
* @return 栈顶fragment
*/
public static Fragment getLastAddFragment(@NonNull FragmentManager fragmentManager) {
List<Fragment> fragments = getFragments(fragmentManager);
if (fragments.isEmpty()) return null;
for (int i = fragments.size() - 1; i >= 0; i--) {
if (fragments.get(i) != null) {
return fragments.get(i);
}
}
return null;
} /**
* 获取栈中最后加入的fragment
*
* @param fragmentManager
* @return
*/
public static Fragment getLastAddFragmentInStack(@NonNull FragmentManager fragmentManager) {
List<Fragment> fragments = getFragments(fragmentManager);
if (fragments.isEmpty()) return null;
for (int i = fragments.size() - 1; i >= 0; i--) {
Fragment fragment = fragments.get(i);
if (fragment != null && fragment.getArguments().getBoolean(ARGS_IS_ADD_STACK)) {
return fragment;
}
}
return null;
} /**
* 获取顶层可见fragment
*
* @param fragmentManager fragment管理器
* @return 栈顶可见fragment
*/
public static Fragment getTopShowFragment(@NonNull FragmentManager fragmentManager) {
return getTopShowFragment(fragmentManager, null);
} /**
* 获取顶层可见fragment
*
* @param fragmentManager fragment管理器
* @param parentFragment 父fragment
* @return 顶层可见fragment
*/
private static Fragment getTopShowFragment(@NonNull FragmentManager fragmentManager,
Fragment parentFragment) {
List<Fragment> fragments = getFragments(fragmentManager);
if (fragments.isEmpty()) return parentFragment;
for (int i = fragments.size() - 1; i >= 0; i--) {
Fragment fragment = fragments.get(i);
if (fragment != null && fragment.isResumed() && fragment.isVisible() && fragment.getUserVisibleHint()) {
return getTopShowFragment(fragment.getChildFragmentManager(), fragment);
}
}
return parentFragment;
} /**
* 获取栈中顶层可见fragment
*
* @param fragmentManager fragment管理器
* @return 栈顶可见fragment
*/
public static Fragment getTopShowFragmentInStack(@NonNull FragmentManager fragmentManager) {
return getTopShowFragmentInStack(fragmentManager, null);
} /**
* 获取栈中顶层可见fragment
*
* @param fragmentManager fragment管理器
* @param parentFragment 父fragment
* @return 顶层可见fragment
*/
private static Fragment getTopShowFragmentInStack(@NonNull FragmentManager fragmentManager,
Fragment parentFragment) {
List<Fragment> fragments = getFragments(fragmentManager);
if (fragments.isEmpty()) return parentFragment;
for (int i = fragments.size() - 1; i >= 0; i--) {
Fragment fragment = fragments.get(i);
if (fragment != null && fragment.isResumed() && fragment.isVisible() && fragment.getUserVisibleHint() && fragment.getArguments().getBoolean(ARGS_IS_ADD_STACK)) {
return getTopShowFragmentInStack(fragment.getChildFragmentManager(), fragment);
}
}
return parentFragment;
} /**
* 查找fragment
*
* @param fragmentManager fragment管理器
*/
public static Fragment findFragment(@NonNull FragmentManager fragmentManager, Class<? extends Fragment> fragmentClass) {
List<Fragment> fragments = getFragments(fragmentManager);
if (fragments.isEmpty()) return null;
return fragmentManager.findFragmentByTag(fragmentClass.getName());
} /**
* 获取目标fragment的前一个fragment
*
* @param fragment 目标fragment
*/
public static Fragment getPreFragment(@NonNull Fragment fragment) {
FragmentManager fragmentManager = fragment.getFragmentManager();
if (fragmentManager == null) return null;
List<Fragment> fragments = getFragments(fragmentManager);
if (fragments.isEmpty()) return null;
int index = fragments.indexOf(fragment);
for (int i = index - 1; i >= 0; i--) {
if (fragments.get(i) != null) {
return fragments.get(i);
}
}
return null;
} /**
* 获取同级别的fragment
*
* @param fragmentManager fragment管理器
* @return 同级别的fragments
*/
public static List<Fragment> getFragments(@NonNull FragmentManager fragmentManager) {
List<Fragment> fragments = fragmentManager.getFragments();
if (fragments == null || fragments.isEmpty()) return Collections.emptyList();
return fragments;
} /**
* 获取所有fragment
*
* @param fragmentManager fragment管理器
* @return 所有fragment
*/
public static List<FragmentNode> getAllFragments(@NonNull FragmentManager fragmentManager) {
return getAllFragments(fragmentManager, new ArrayList<FragmentNode>());
} /**
* 获取所有fragment
*
* @param fragmentManager fragment管理器
* @param result 结果
* @return 所有fragment
*/
private static List<FragmentNode> getAllFragments(@NonNull FragmentManager fragmentManager,
List<FragmentNode> result) {
List<Fragment> fragments = fragmentManager.getFragments();
if (fragments == null || fragments.isEmpty()) return Collections.emptyList();
for (int i = fragments.size() - 1; i >= 0; i--) {
Fragment fragment = fragments.get(i);
if (fragments.get(i) == null) continue;
result.add(new FragmentNode(fragment, getAllFragments(fragment.getChildFragmentManager(), new ArrayList<FragmentNode>())));
}
return result;
} /**
* 获取回退栈中的fragment
* <p>需之前对fragment的操作都借助该工具类</p>
*
* @param fragmentManager fragment管理器
* @return 回退栈中的fragment
*/
public static List<FragmentNode> getAllFragmentsInStack(@NonNull FragmentManager fragmentManager) {
List<Fragment> fragments = fragmentManager.getFragments();
if (fragments == null || fragments.isEmpty()) return Collections.emptyList();
List<FragmentNode> result = new ArrayList<>();
for (int i = fragments.size() - 1; i >= 0; i--) {
Fragment fragment = fragments.get(i);
if (fragments.get(i) != null && fragment.getArguments().getBoolean(ARGS_IS_ADD_STACK)) {
result.add(new FragmentNode(fragment, getAllFragments(fragment.getChildFragmentManager(), new ArrayList<FragmentNode>())));
}
}
return result;
} /**
* 处理fragment回退键
* <p>如果fragment实现了OnBackClickListener接口,返回{@code true}: 表示已消费回退键事件,反之则没消费</p>
* <p>具体示例见FragmentActivity</p>
*
* @param fragment fragment
* @return 是否消费回退事件
*/
public static boolean dispatchBackPress(@NonNull Fragment fragment) {
return dispatchBackPress(fragment.getFragmentManager());
} /**
* 处理fragment回退键
* <p>如果fragment实现了OnBackClickListener接口,返回{@code true}: 表示已消费回退键事件,反之则没消费</p>
* <p>具体示例见FragmentActivity</p>
*
* @param fragmentManager fragment管理器
* @return 是否消费回退事件
*/
public static boolean dispatchBackPress(@NonNull FragmentManager fragmentManager) {
List<Fragment> fragments = fragmentManager.getFragments();
if (fragments == null || fragments.isEmpty()) return false;
for (int i = fragments.size() - 1; i >= 0; i--) {
Fragment fragment = fragments.get(i);
if (fragment != null
&& fragment.isResumed()
&& fragment.isVisible()
&& fragment.getUserVisibleHint()
&& fragment instanceof OnBackClickListener
&& ((OnBackClickListener) fragment).onBackClick()) {
return true;
}
}
return false;
} /**
* 设置背景色
*
* @param fragment fragment
* @param color 背景色
*/
public static void setBackgroundColor(@NonNull Fragment fragment, @ColorInt int color) {
View view = fragment.getView();
if (view != null) {
view.setBackgroundColor(color);
}
} /**
* 设置背景资源
*
* @param fragment fragment
* @param resId 资源Id
*/
public static void setBackgroundResource(@NonNull Fragment fragment, @DrawableRes int resId) {
View view = fragment.getView();
if (view != null) {
view.setBackgroundResource(resId);
}
} /**
* 设置背景
*
* @param fragment fragment
* @param background 背景
*/
public static void setBackground(@NonNull Fragment fragment, Drawable background) {
View view = fragment.getView();
if (view != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
view.setBackground(background);
} else {
view.setBackgroundDrawable(background);
}
}
} static class Args {
int id;
boolean isHide;
boolean isAddStack; Args(int id, boolean isHide, boolean isAddStack) {
this.id = id;
this.isHide = isHide;
this.isAddStack = isAddStack;
}
} public static class SharedElement {
View sharedElement;
String name; public SharedElement(View sharedElement, String name) {
this.sharedElement = sharedElement;
this.name = name;
}
} static class FragmentNode {
Fragment fragment;
List<FragmentNode> next; public FragmentNode(Fragment fragment, List<FragmentNode> next) {
this.fragment = fragment;
this.next = next;
} @Override
public String toString() {
return fragment.getClass().getSimpleName() + "->" + ((next == null || next.isEmpty()) ? "no child" : next.toString());
}
} public interface OnBackClickListener {
boolean onBackClick();
}
}

终点站

好了,终点站到了,如果对本次旅途满意的话,请给五星好评哦,毕竟老司机牺牲了很多时间才换来这么一份工具类,如果该工具类依赖其他工具类,都可以在我的Android开发人员不得不收集的代码(持续更新中)中找到。

Fragment管理工具类的更多相关文章

  1. android的Log日志打印管理工具类(一)

    android的Log日志的打印管理工具类: package com.gzcivil.utils; import android.util.Log; /** * 日志打印管理 * * @author ...

  2. Android 软件管理工具类Utils

    Android 软件管理工具类Utils /** * Created by uilubo on 2015/9/30. * 工具类 */ public class Utils { public stat ...

  3. 阶段3 2.Spring_07.银行转账案例_4 编写事务管理工具类并分析连接和线程解绑

    事务管理工具类 首先需要有connection.并且是当前线程上的connection.声明connectionUtils.提供set方法等着spring来注入 有异常需要放在事务里面 close关闭 ...

  4. Dialog对话框管理工具类

    import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; i ...

  5. 可以获取JVM信息的一些管理工具类

    一些可以获取JVM信息的java工具类 BufferPoolMXBean.class ClassLoadingMXBean.class CompilationMXBean.class GarbageC ...

  6. 【Android工具类】Activity管理工具类AppManager

    转载请注明出处:http://blog.csdn.net/zhaokaiqiang1992 import java.util.Stack; import android.app.Activity; i ...

  7. 【笔记】cookies管理工具类

    package com.ulearning.ulms.util; import java.io.UnsupportedEncodingException; import java.net.URLDec ...

  8. Logger日志管理工具类

    import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import j ...

  9. JBPM4入门——4.封装流程管理的工具类(JbpmUtil)

    本博文只是简要对JBPM4进行介绍,如需更详细内容请自行google 链接: JBPM入门系列文章: JBPM4入门——1.jbpm简要介绍 JBPM4入门——2.在eclipse中安装绘制jbpm流 ...

随机推荐

  1. 03-老马jQuery教程-DOM操作

    jQuery DOM操作 在没有jQuery之前,DOM的操作相对来说有点麻烦,尤其是DOM节点的搜索.目前我们已经学习了jQuery的选择器,接下带大家一块学习jQuery的DOM操作,jQuery ...

  2. 3. EM算法-高斯混合模型GMM

    1. EM算法-数学基础 2. EM算法-原理详解 3. EM算法-高斯混合模型GMM 4. EM算法-高斯混合模型GMM详细代码实现 5. EM算法-高斯混合模型GMM+Lasso 1. 前言 GM ...

  3. Android 开发自己的网络收音机2——电台列表(SlidingMenu侧滑栏)

    上一篇文章总体规划了这个项目的情况,今天讲讲实现电台列表.今天其实主要想讲解的是SlidingMenu,也就是我们平时说的侧滑栏,现在很多应用都有用这种UI效果.SlidingMenu侧滑栏功能实现的 ...

  4. 【转】Ext.Window动态修改html

    原文地址:http://www.codeweblog.com/ext-window%E5%8A%A8%E6%80%81%E4%BF%AE%E6%94%B9html/ Ext.Window动态修改htm ...

  5. 卡西欧(casio)Fx-5800p程序调试器||模拟器V1.0

    一.[背景] 都说这个卡西欧5800p没有模拟器,模拟器其实就是个电脑上面模拟他的界面的东西,但是真正的核心,他不一定有,而且我们测量方面的编程及时有了所谓的外形模拟器也学不会的. 都说这个卡西欧58 ...

  6. [Linux实用工具]Windows下同步Linux文件(Linux安装Samba和配置)

    场景需求: 安装了Ubuntu在虚拟机上,但是代码编辑或者其它更多的操作的时候,还是习惯在windows下进行.如果windows下编辑完再上传到服务器,再编译执行,就太繁琐了.一次两次还好说,这编译 ...

  7. CentOS7安装MySQL5.7常见问题

    下载与安装 亲测有效: https://www.linuxidc.com/Linux/2016-09/135288.htm 设置MySQL服务开机自启动 注意,CentOS6和7有一点不同:CentO ...

  8. Chrome 插件编写日记

    Chrome 插件,你可以理解为打开了一个网页,但是里面只有前端语言,JavaScript, HTML + css 但是有一点区别的是,它是有一个名字为 manifest.json 的配置文件的,里面 ...

  9. android——官方下拉刷新组件SwipeRefreshLayout(转)

    一.问题描述 在android开发中,使用最多的数据刷新方式就是下拉刷新了,而完成此功能我们使用最多的就是第三方的开源库PullToRefresh.现如今,google也忍不住推出了自己的下拉组件Sw ...

  10. Java编程的逻辑 (40) - 剖析HashMap

    本系列文章经补充和完善,已修订整理成书<Java编程的逻辑>,由机械工业出版社华章分社出版,于2018年1月上市热销,读者好评如潮!各大网店和书店有售,欢迎购买,京东自营链接:http:/ ...