一个很好用的小控件----给所有view右上角添加数字(类似未读消息之类的)

2023-11-13

下面这种效果:
这里写图片描述

Badge 用法很简但 见下面的demo:

/**
* Created by Fangchao on 2015/2/25.
*/
@EActivity(R.layout.activity_usercenter)
public class UserCenterActivity extends BaseActionBarActivity implements DataHelper.DataListener {
@ViewById(R.id.person_detail_headImage)
CircleImageView headImageV;// 头像
@ViewById(R.id.person_detail_name)
TextView nameV;// 会员账户
@ViewById(R.id.person_detail_level)
ImageView levelV;
@ViewById(R.id.person_detail_price)
TextView priceV;// 账户余额

@ViewById(R.id.person_detail_paycount)
Button payCountV;// 待付款
@ViewById(R.id.person_detail_noReceipt)
Button noReceiptV;// 待收货

@ViewById(R.id.person_detail_eaid)
Button eaidV;// 待评价

BadgeView payCountBadge;// 待付款 数量
BadgeView noReceiptBadge;// 待收货 数量
BadgeView eaidBadge;// 待评价 数量


// 数据
DataHelper mDataHelper;

@AfterViews
void initview() {

    initdata();
}

@Click({R.id.person_detail_exit})
void click(View view) {
    switch (view.getId()) {
        case R.id.person_detail_exit:
            SharedPreferencesUtils.getInstance().cleanUserMessage();
            setResult(RESULT_OK);
            finish();
            break;
    }
}

private void initdata() {
    UserBean bean = SharedPreferencesUtils.getInstance().getUserMessage();
    // 赋值
    ImageLoader mImageLoader = new ImageLoader(MyApplication.getInstance()
            .getRequestQueue(), BitmapCache.getInstance());
    // 给view设置值
    headImageV.setDefaultImageResId(R.drawable.ic_logo);
    headImageV.setErrorImageResId(R.drawable.ic_logo);
    headImageV.setImageUrl(bean.getImageUrl(), mImageLoader);
    nameV.setText(bean.getAccount());
    // 等级赋值
    if ("1".equals(bean.getLevel())) {
        levelV.setImageResource(R.drawable.ready_bojin);
    } else if ("2".equals(bean.getLevel())) {
        levelV.setImageResource(R.drawable.ready_bojin);
    } else if ("3".equals(bean.getLevel())) {
        levelV.setImageResource(R.drawable.ready_bojin);
    } else if ("4".equals(bean.getLevel())) {
        levelV.setImageResource(R.drawable.ready_bojin);
    }
    priceV.setText("余额:" + PriceTools.formatStr(bean.getPrice()));

    // 数字动画
    TranslateAnimation anim = new TranslateAnimation(-100, 0, 0, 0);
    anim.setInterpolator(new BounceInterpolator());
    anim.setDuration(1000);
    // 避免反复添加数字view覆盖问题所以加此判断
    try {
        if (Integer.parseInt(bean.getPaycount().trim()) != 0) {
            if (payCountBadge != null) {
                payCountBadge.setText(bean.getPaycount());
            } else {
                payCountBadge = getBadgeV(payCountV, bean.getPaycount());
                payCountBadge.show(anim);
            }
        }
        if (Integer.parseInt(bean.getNoReceipt().trim()) != 0) {
            if (noReceiptBadge != null && bean.getNoReceipt().trim() != "0") {
                noReceiptBadge.setText(bean.getNoReceipt());

            } else {
                noReceiptBadge = getBadgeV(noReceiptV, bean.getNoReceipt());
                noReceiptBadge.show(anim);
            }
        }
        if (Integer.parseInt(bean.getEaid().trim()) != 0) {
            if (eaidBadge != null) {
                eaidBadge.setText(bean.getEaid());


            } else {
                eaidBadge = getBadgeV(eaidV, bean.getEaid());
                eaidBadge.show(anim);
            }
        }
    } catch (NumberFormatException e) {
        e.printStackTrace();
    }
}

@Override
public void onResume() {
    super.onResume();
    initDataWithNetWork();
}

@Override
protected void onDestroy() {
    super.onDestroy();
    if (mDataHelper != null)
        mDataHelper.cancel();
}

/**
 * 获取用户信息通过网络
 */
private void initDataWithNetWork() {
    if (SharedPreferencesUtils.getInstance().isLogin()) {
        mDataHelper = new PostDataHelper(URLHelper.getURL(
                URLHelper.MODULE_ACCOUNT, URLHelper.M_GETMEMBERINFO),
                URLHelper.getBaseParams(URLHelper.M_GETMEMBERINFO), this, 0);
        mDataHelper.execute();
    }
}

/**
 * 获取数字view
 *
 * @param v
 * @param str
 * @return
 */
private BadgeView getBadgeV(View v, String str) {
    BadgeView mBadgeView = new BadgeView(this, v);
    mBadgeView.setText(str);
    mBadgeView.setBadgeMargin(10, 0);
    mBadgeView.setBadgeBackgroundColor(Color.parseColor("#E5004A"));//设置badgeview的背景色
    return mBadgeView;
}

@Override
public void sucess(JSONObject response, int code) {
    switch (code) {
        case 0:
            if (!UserCenterActivity.this.isFinishing()) {
                ResultSingleBean rb = (ResultSingleBean) VolleyResponseHelper
                        .jsonToBean(response, 4);
                if (rb.getRetCode() == 0) {
                    // 登陆成功
                    UserBean bean = (UserBean) rb.getRetObj();
                    SharedPreferencesUtils.getInstance().editUserMessage(bean);
                    initdata();
                } else {
                    CustomToast.showToast(rb.getRetMessage(), this);
                }
            }
            break;

        default:
            break;
    }
}

@Override
public void err(String error, int code) {
    CustomToast.showToast(error, this);
}

}

代码跳着看就行,懒得往外摘了

BadgeView 类下载:
算了不用下了,还麻烦,就一个类:复制过去用就行了:

package com.readystatesoftware.viewbadger;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewParent;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.TabWidget;
import android.widget.TextView;

/**
 * A simple text label view that can be applied as a "badge" to any given {@link android.view.View}. 
 * This class is intended to be instantiated at runtime rather than included in XML layouts.
 * 
 * @author Jeff Gilfelt
 */
public class BadgeView extends TextView {

    public static final int POSITION_TOP_LEFT = 1;
    public static final int POSITION_TOP_RIGHT = 2;
    public static final int POSITION_BOTTOM_LEFT = 3;
    public static final int POSITION_BOTTOM_RIGHT = 4;
    public static final int POSITION_CENTER = 5;

    private static final int DEFAULT_MARGIN_DIP = 5;
    private static final int DEFAULT_LR_PADDING_DIP = 5;
    private static final int DEFAULT_CORNER_RADIUS_DIP = 8;
    private static final int DEFAULT_POSITION = POSITION_TOP_RIGHT;
    //private static final int DEFAULT_BADGE_COLOR = Color.parseColor("#CCFF0000"); //Color.RED;
    private static final int DEFAULT_BADGE_COLOR = Color.RED; //Color.RED;
    private static final int DEFAULT_TEXT_COLOR = Color.WHITE;

    private static Animation fadeIn;
    private static Animation fadeOut;

    private Context context;
    private View target;

    private int badgePosition;
    private int badgeMarginH;
    private int badgeMarginV;
    private int badgeColor;

    private boolean isShown;

    private ShapeDrawable badgeBg;

    private int targetTabIndex;

    public BadgeView(Context context) {
        this(context, (AttributeSet) null, android.R.attr.textViewStyle);
    }

    public BadgeView(Context context, AttributeSet attrs) {
         this(context, attrs, android.R.attr.textViewStyle);
    }

    /**
     * Constructor -
     * 
     * create a new BadgeView instance attached to a target {@link android.view.View}.
     *
     * @param context context for this view.
     * @param target the View to attach the badge to.
     */
    public BadgeView(Context context, View target) {
         this(context, null, android.R.attr.textViewStyle, target, 0);
    }

    /**
     * Constructor -
     * 
     * create a new BadgeView instance attached to a target {@link android.widget.TabWidget}
     * tab at a given index.
     *
     * @param context context for this view.
     * @param target the TabWidget to attach the badge to.
     * @param index the position of the tab within the target.
     */
    public BadgeView(Context context, TabWidget target, int index) {
        this(context, null, android.R.attr.textViewStyle, target, index);
    }

    public BadgeView(Context context, AttributeSet attrs, int defStyle) {
        this(context, attrs, defStyle, null, 0);
    }

    public BadgeView(Context context, AttributeSet attrs, int defStyle, View target, int tabIndex) {
        super(context, attrs, defStyle);
        init(context, target, tabIndex);
    }

    private void init(Context context, View target, int tabIndex) {

        this.context = context;
        this.target = target;
        this.targetTabIndex = tabIndex;

        // apply defaults
        badgePosition = DEFAULT_POSITION;
        badgeMarginH = dipToPixels(DEFAULT_MARGIN_DIP);
        badgeMarginV = badgeMarginH;
        badgeColor = DEFAULT_BADGE_COLOR;

        setTypeface(Typeface.DEFAULT_BOLD);
        int paddingPixels = dipToPixels(DEFAULT_LR_PADDING_DIP);
        setPadding(paddingPixels, 0, paddingPixels, 0);
        setTextColor(DEFAULT_TEXT_COLOR);

        fadeIn = new AlphaAnimation(0, 1);
        fadeIn.setInterpolator(new DecelerateInterpolator());
        fadeIn.setDuration(200);

        fadeOut = new AlphaAnimation(1, 0);
        fadeOut.setInterpolator(new AccelerateInterpolator());
        fadeOut.setDuration(200);

        isShown = false;

        if (this.target != null) {
            applyTo(this.target);
        } else {
            show();
        }

    }

    private void applyTo(View target) {

        LayoutParams lp = target.getLayoutParams();
        ViewParent parent = target.getParent();
        FrameLayout container = new FrameLayout(context);

        if (target instanceof TabWidget) {

            // set target to the relevant tab child container
            target = ((TabWidget) target).getChildTabViewAt(targetTabIndex);
            this.target = target;

            ((ViewGroup) target).addView(container, 
                    new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

            this.setVisibility(View.GONE);
            container.addView(this);

        } else {

            // TODO verify that parent is indeed a ViewGroup
            ViewGroup group = (ViewGroup) parent; 
            int index = group.indexOfChild(target);

            group.removeView(target);
            group.addView(container, index, lp);

            container.addView(target);

            this.setVisibility(View.GONE);
            container.addView(this);

            group.invalidate();

        }

    }

    /**
     * Make the badge visible in the UI.
     * 
     */
    public void show() {
        show(false, null);
    }

    /**
     * Make the badge visible in the UI.
     *
     * @param animate flag to apply the default fade-in animation.
     */
    public void show(boolean animate) {
        show(animate, fadeIn);
    }

    /**
     * Make the badge visible in the UI.
     *
     * @param anim Animation to apply to the view when made visible.
     */
    public void show(Animation anim) {
        show(true, anim);
    }

    /**
     * Make the badge non-visible in the UI.
     * 
     */
    public void hide() {
        hide(false, null);
    }

    /**
     * Make the badge non-visible in the UI.
     *
     * @param animate flag to apply the default fade-out animation.
     */
    public void hide(boolean animate) {
        hide(animate, fadeOut);
    }

    /**
     * Make the badge non-visible in the UI.
     *
     * @param anim Animation to apply to the view when made non-visible.
     */
    public void hide(Animation anim) {
        hide(true, anim);
    }

    /**
     * Toggle the badge visibility in the UI.
     * 
     */
    public void toggle() {
        toggle(false, null, null);
    }

    /**
     * Toggle the badge visibility in the UI.
     * 
     * @param animate flag to apply the default fade-in/out animation.
     */
    public void toggle(boolean animate) {
        toggle(animate, fadeIn, fadeOut);
    }

    /**
     * Toggle the badge visibility in the UI.
     *
     * @param animIn Animation to apply to the view when made visible.
     * @param animOut Animation to apply to the view when made non-visible.
     */
    public void toggle(Animation animIn, Animation animOut) {
        toggle(true, animIn, animOut);
    }

    private void show(boolean animate, Animation anim) {
        if (getBackground() == null) {
            if (badgeBg == null) {
                badgeBg = getDefaultBackground();
            }
            setBackgroundDrawable(badgeBg);
        }
        applyLayoutParams();

        if (animate) {
            this.startAnimation(anim);
        }
        this.setVisibility(View.VISIBLE);
        isShown = true;
    }

    private void hide(boolean animate, Animation anim) {
        this.setVisibility(View.GONE);
        if (animate) {
            this.startAnimation(anim);
        }
        isShown = false;
    }

    private void toggle(boolean animate, Animation animIn, Animation animOut) {
        if (isShown) {
            hide(animate && (animOut != null), animOut);    
        } else {
            show(animate && (animIn != null), animIn);
        }
    }

    /**
     * Increment the numeric badge label. If the current badge label cannot be converted to
     * an integer value, its label will be set to "0".
     * 
     * @param offset the increment offset.
     */
    public int increment(int offset) {
        CharSequence txt = getText();
        int i;
        if (txt != null) {
            try {
                i = Integer.parseInt(txt.toString());
            } catch (NumberFormatException e) {
                i = 0;
            }
        } else {
            i = 0;
        }
        i = i + offset;
        setText(String.valueOf(i));
        return i;
    }

    /**
     * Decrement the numeric badge label. If the current badge label cannot be converted to
     * an integer value, its label will be set to "0".
     * 
     * @param offset the decrement offset.
     */
    public int decrement(int offset) {
        return increment(-offset);
    }

    private ShapeDrawable getDefaultBackground() {

        int r = dipToPixels(DEFAULT_CORNER_RADIUS_DIP);
        float[] outerR = new float[] {r, r, r, r, r, r, r, r};

        RoundRectShape rr = new RoundRectShape(outerR, null, null);
        ShapeDrawable drawable = new ShapeDrawable(rr);
        drawable.getPaint().setColor(badgeColor);

        return drawable;

    }

    private void applyLayoutParams() {

        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

        switch (badgePosition) {
        case POSITION_TOP_LEFT:
            lp.gravity = Gravity.LEFT | Gravity.TOP;
            lp.setMargins(badgeMarginH, badgeMarginV, 0, 0);
            break;
        case POSITION_TOP_RIGHT:
            lp.gravity = Gravity.RIGHT | Gravity.TOP;
            lp.setMargins(0, badgeMarginV, badgeMarginH, 0);
            break;
        case POSITION_BOTTOM_LEFT:
            lp.gravity = Gravity.LEFT | Gravity.BOTTOM;
            lp.setMargins(badgeMarginH, 0, 0, badgeMarginV);
            break;
        case POSITION_BOTTOM_RIGHT:
            lp.gravity = Gravity.RIGHT | Gravity.BOTTOM;
            lp.setMargins(0, 0, badgeMarginH, badgeMarginV);
            break;
        case POSITION_CENTER:
            lp.gravity = Gravity.CENTER;
            lp.setMargins(0, 0, 0, 0);
            break;
        default:
            break;
        }

        setLayoutParams(lp);

    }

    /**
     * Returns the target View this badge has been attached to.
     * 
     */
    public View getTarget() {
        return target;
    }

    /**
     * Is this badge currently visible in the UI?
     * 
     */
    @Override
    public boolean isShown() {
        return isShown;
    }

    /**
     * Returns the positioning of this badge.
     * 
     * one of POSITION_TOP_LEFT, POSITION_TOP_RIGHT, POSITION_BOTTOM_LEFT, POSITION_BOTTOM_RIGHT, POSTION_CENTER.
     * 
     */
    public int getBadgePosition() {
        return badgePosition;
    }

    /**
     * Set the positioning of this badge.
     * 
     * @param layoutPosition one of POSITION_TOP_LEFT, POSITION_TOP_RIGHT, POSITION_BOTTOM_LEFT, POSITION_BOTTOM_RIGHT, POSTION_CENTER.
     * 
     */
    public void setBadgePosition(int layoutPosition) {
        this.badgePosition = layoutPosition;
    }

    /**
     * Returns the horizontal margin from the target View that is applied to this badge.
     * 
     */
    public int getHorizontalBadgeMargin() {
        return badgeMarginH;
    }

    /**
     * Returns the vertical margin from the target View that is applied to this badge.
     * 
     */
    public int getVerticalBadgeMargin() {
        return badgeMarginV;
    }

    /**
     * Set the horizontal/vertical margin from the target View that is applied to this badge.
     * 
     * @param badgeMargin the margin in pixels.
     */
    public void setBadgeMargin(int badgeMargin) {
        this.badgeMarginH = badgeMargin;
        this.badgeMarginV = badgeMargin;
    }

    /**
     * Set the horizontal/vertical margin from the target View that is applied to this badge.
     * 
     * @param horizontal margin in pixels.
     * @param vertical margin in pixels.
     */
    public void setBadgeMargin(int horizontal, int vertical) {
        this.badgeMarginH = horizontal;
        this.badgeMarginV = vertical;
    }

    /**
     * Returns the color value of the badge background.
     * 
     */
    public int getBadgeBackgroundColor() {
        return badgeColor;
    }

    /**
     * Set the color value of the badge background.
     * 
     * @param badgeColor the badge background color.
     */
    public void setBadgeBackgroundColor(int badgeColor) {
        this.badgeColor = badgeColor;
        badgeBg = getDefaultBackground();
    }

    private int dipToPixels(int dip) {
        Resources r = getResources();
        float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, r.getDisplayMetrics());
        return (int) px;
    }

}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

一个很好用的小控件----给所有view右上角添加数字(类似未读消息之类的) 的相关文章

  • 自定义view之水波浪进度球

    这段时间项目做完了 本以为可以偷懒一段时间 结果领导又接了一个车载项目让我做 很气但是没办法 还是得搞 谁让我是搬砖的呢 今天搞了一个水波纹的自定义控件 先看效果 第一眼还是觉得可以看的 其实我觉得有点丑 ui妹子说挺好看 好吧 那就这样吧
  • 【UE4从零开始 021】控件类型介绍

    1 Common 选项 说明 边框 Border 边框是容器控件 可以包含一个子控件 提供使用边框图像和可调节的填补将其包围起来的机会 按钮 Button 按钮是单子项 可点击的Primitive控件 它可实现基本交互 你可将任何其他控件放
  • QML树控件TreeView的使用(上)

    在Qt5 5之前是没有树控件的 我们在使用时用的是ListView来构造出一个树 Qt5 5之后的QML开发阶段 有了树控件TreeView 本篇着重记录QML的TreeView的使用 根据MVC分解文件 类 如下 TreeControll
  • 解决Activity中或fragment时,点击手机返回键无效,无法触发onKeyDown

    Activity中或fragment时部分页面点击手机返回键无效 尤其是在页面第一次创建的时候和searchView获取焦点的时候会出现这种情况 那是因为你加载的fragement或Activity中嵌套了searchView控件的问题 虽
  • Android 01:AutoCompleteTextView-简单实现实现自动输入文本效果

    在Android中 可以使用控件AutoCompleteTextView实现自动输入的文本功能 当用户输入一个字符 能够根据其字符提示显示出与之相关的数据 举大家一个熟悉的例子 当我们在百度中输入关键字 android 在列表中会出现相关的
  • 一步一步学android控件(之六) —— MultiAutoCompleteTextView

    今天学习的控件是MultiAutoCompleteTextView 提到MultiAutoCompleteTextView 我们就自然而然地想到AutoCompleteTextView 就想知道他们之间到底有什么区别 在讲他们区别之前呢先来
  • Android-自定义UI模板

    我们要用UI模板的时候 如果所有的Topbar内容都是没有变的话 那我们用在xml文件中include进去就好了 但是如果Topbar中的内容是会随着fragment或者activity改变的话 拿我们总不能每次都去写多个文件 再分别inc
  • 一个很好用的小控件----给所有view右上角添加数字(类似未读消息之类的)

    下面这种效果 Badge 用法很简但 见下面的demo Created by Fangchao on 2015 2 25 EActivity R layout activity usercenter public class UserCen
  • jQuery dataTables 的使用

    jQuery 的插件 dataTables 是一个优秀的表格插件 提供了针对表格的排序 浏览器分页 服务器分页 筛选 格式化等功能 dataTables 的网站上也提供了大量的演示和详细的文档进行说明 为了方便学习使用 这里一步一步进行说明
  • android 实现自动输入文本效果

    此控件的功能是帮助用户实现自动输入 例如当用户输入一个字符后 能够根据这个字符提示显示出与之相关的数据 里面用到了一个适配器来实现此功能 源代码如下 package com example autosearch import android
  • Qt中窗体控件按照比例缩放,自适应窗口大小进行布局

    最近在做本科毕设 用到了Qt 无奈本人实在是太过于小白了 很多东西都进行了很久的探索 比如今天说到的窗体控件布局 一把辛酸泪 首先就是创建一个GUI文件 然后进行UI设计 这里就只需要从左边进行拖拽 这个很easy啦 然后对其进行布局 比如
  • BottomSheetDialogFragment圆角

    自己使用BottomSheetDialogFragment时 想实现上方圆角 布局设置了圆角的背景后 需要给dialog的北京设置为透明 才能有圆角的效果 网上其他的文章都是这么实现的 dialog getWindow findViewBy
  • 微信小程序常用表单控件

    感谢慕课网七月老师课程 如何一次性获取所有表单控件的值并且提交到服务器上去呢 from表单提交 使用form把所有子元素包含进去
  • daily-timeline.js——打造每日时间轴

    最近因为需要在做会议室预约系统 其中需要用到一个显示当天预约情况的时间轴 去网上找了一下 发现只有和微博类似的历史时间轴 于是便自己动手做了一个当日时间轴控件 daily timeline js 实际使用效果如下 原理是Canvas的绘制
  • 如何在 iOS 推送通知上增加徽章

    我目前正在从有效负载中获取徽章 但我怎样才能更新这个值 aps alert Notification Hub test notification2 badge 1 sound Default 当我发送此消息时 徽章编号中始终显示 1 但是当
  • 如何使用 BadgeDrawable 在汉堡导航菜单图标上添加徽章?

    I add Badge在像这样的按钮上this way 我想添加Badge on hamburger navigation菜单图标用这种方式 但我不知道如何 我找到了一些解决方案 但没有用BadgeDrawable 这是我的代码 但结果不是
  • 设计可插入积分和徽章系统[关闭]

    Closed 这个问题需要细节或清晰度 目前不接受答案 如何设计一个可插拔积分和徽章系统 既易于打开和关闭 又易于变成自己的模块 经过多次试验和错误 我得出的结论是 积分和徽章与应用程序的唯一业务逻辑过于交织在一起 无法以简单的方式将它们具
  • 如何在选项卡布局中显示通知计数器?

    I saw 这个堆栈溢出帖子 https stackoverflow com questions 32269517 how to show unread notification counter on tabs inside tablayo
  • Woot-badge 就像 PHP 中的一样

    有谁知道如何在用 PHP 编写的网站中实现某些功能 类似于堆栈溢出上的 Woot badge 和 Fanatic badge 我想奖励我的用户 如果他们连续 75 天每天访问我的网站 没有一天不访问它 我的网站使用会话进行登录 我使用 My
  • Android 操作项上的通知徽章

    我想在操作栏中放置的购物车图像上添加一个通知徽章 并以编程方式操作它 有帮助吗 您可以显示自定义MenuItem on ActionBar通过创建一个custom layout for MenuItem 要设置自定义布局 您必须使用菜单项属

随机推荐

  • java 各省市区代码表

    因最近项目开发需要用到全国各省市区的城市编码 网上找了好久 终于找到了非常全的 现记录一下 方便以后使用 DROP TABLE IF EXISTS region CREATE TABLE region id int 10 NOT NULL
  • OpenCL-学习教程(二)

    经过两天的摸爬滚打 基本上了解了opencl的并行处理的原理和内部调用机制 也上手写代码调试了几个工程 总体感觉opencl会比cuda比起来更复杂一些 但不得不说 平台的兼容性更好 而且调试应该方便些 虽然我的VS调试配置环境始终有问题
  • python的itchat模块

    今天一不小心发现的python的好玩模块itchar 首先 安装 pip install itchat 1 搜索微信好友信息 import itchat itchat auto login hotReload True 登入 friends
  • MTK 调试记录

    MT8788 MT8183 使用CC1 CC2做OTG检测 CONFIG MTK USB TYPEC U3 MUX 关闭 打开一下宏 CONFIG TCPC CLASS y CONFIG TCPC MT6370 y CONFIG MTK U
  • 常见等价无穷小

    当 x 0 时 等 价 无 穷
  • c++stl和std_std :: replace()函数以及C ++ STL中的示例

    c stl和std C STL std replace 函数 C STL std replace function replace function is a library function of algorithm header it
  • IntelliJ IDEA的项目配置和创建项目(四)

    一 配置JDK 按 Ctrl Shift Alt S 快捷键就会弹出项目配置区 如下图 第一个红色区域是配置JDK的地方 第二个红色区域指的是项目编译后输出的路径 如果要设置Modules项目的jdk 那么可以在这一行设置 二 创建项目 创
  • MyBatis-Plus 官方文档

    myBatis plus 官方文档 https mp baomidou com
  • VUE父组件监听$emit事件,如何传递多个父组件自己的参数

    背景 子组件可以通过this emit change parm value1 parm2 value2 传递多个参数 父组件监听事件传参有两种方式 方式1 父组件自己无参数 方法名可以不用带参数 函数中的e代表change事件的对象 直接获
  • 数据库系统概论-数据库恢复技术

    1 事务的概念及其特性 恢复技术能保证事务的哪些特性 事务是用户定义的一个数据库操作序列 这些操作要么全做 要么全不做 是一个不可分割的工作单位 事务具有4个特性 原子性 Atomicity 一致性 Consistency 隔离性 Isol
  • Java6.0中Comparable接口与Comparator接口详解 下

    Part IV 说到现在 读者应该对Comparable接口有了大概的了解 但是为什么又要有一个Comparator接口呢 难道Java的开发者都吃饱撑着没事做吗 再谈Comparator接口之前 大家应该先了解一个叫 策略模式 的东东 一
  • WIN10操作系统 Visual Studio 2017 C# ASP.net Web 简单接口+MySQL数据库+NPOI导出到EXCEL开发、发布及部署到局域网详细教程(一)

    本文利用Visual Studio 2017 C 编写一个简单的WEB程序发布和部署到局域网内 目的是实现 在局域网内任意一台未安装OFFICE办公软件的电脑上打开浏览器后在地址栏输入IP地址和端口号 即可链接到WEB网页 点击 导出到EX
  • Linux 镜像文件ISO下载

    Linux 镜像文件ISO下载地址 http archive kernel org centos vault 7 5 1804 isos x86 64 选择 CentOS 7 x86 64 Minimal 1804 iso 下载就OK 下载
  • 华为机试题81-字符串字符匹配

    描述 判断短字符串S中的所有字符是否在长字符串T中全部出现 请注意本题有多组样例输入 数据范围 1 len S len T 200 进阶 时间复杂度 O n 空间复杂度 O n 输入描述 输入两个字符串 第一个为短字符串 第二个为长字符串
  • 登录工程二:现代 Web 应用的典型身份验证需求

    朋友就职于某大型互联网公司 前不久 在闲聊间我问他日常工作的内容 他说他所在部门只负责一件事 即用户与登录 而他的具体工作则是为各个业务子网站提供友好的登录部件 Widget 从而统一整个网站群的登录体验 同时也能令业务开发者不用花费额外的
  • 解决MySQL版本与JDBC驱动版本不对应导致的错误

    我的MySQL版本是5 7 21的 对应的JDBC驱动应该是mysql connector java 5 1 46 bin jar 如果使用低版本的驱动 就会出现如下错误 HTTP Status 500 javax servlet Serv
  • .exe已停止工作_R027---Uipath调用python程序的exe

    一 缘起 看到不少朋友问Uipath调用python的方法 这里说一个方法 调用python程序编译后的exe 其他开发语言的程序也可以这么调用 由于调用的是exe文件 所以 其实没有用到UiPath Python Activities 用
  • Ubuntu常用命令大全

    转自 https www jb51 net os Ubuntu 56362 html 一 文件 文件夹管理 ls 列出当前目录文件 不包括隐含文件 ls a 列出当前目录文件 包括隐含文件 ls l 列出当前目录下文件的详细信息 cd 回当
  • 层次分析法的理解

    AHP 层次分析法 层次分析法的特点 基本概念 重要性表 判断矩阵 为什么要引入判断矩阵呢 判断矩阵的特点 一致矩阵 为什么要定义一致矩阵呢 一致矩阵的特点 一致矩阵的引理 一致性检验的步骤 判断矩阵计算权重 算术平均法求权重 几何平均法
  • 一个很好用的小控件----给所有view右上角添加数字(类似未读消息之类的)

    下面这种效果 Badge 用法很简但 见下面的demo Created by Fangchao on 2015 2 25 EActivity R layout activity usercenter public class UserCen