Android 购物车数量加减

github地址

  • 1.在项目根目录添加
allprojects {

repositories {

maven { url 'https://jitpack.io' }

}
}
  • 2.在项目目录build.gradle添加
dependencies {
compile 'com.github.d746997:ShopcartCode:1.1'
}
    1. xml引用
android:id="@+id/add"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

app:addtextbg="@drawable/box_val"

app:alltextsize="5sp"

app:buttonheight="30dp"

app:buttonwidth="30dp"

app:minustextbg="@drawable/box_val"

app:textbg="@color/white"

app:textcolor="@color/colorPrimary"

app:textwidth="60dp"

/>
  • 4.activity 使用
@BindView(R.id.add)

AddMinusView add;

add.setInventory(20)  //库存大小

.setOnNowNumListener(new AddMinusView.onNumListener() {

@Override

public void onNowNum(int i) {

Toast.makeText(MainActivity.this, ""+i, Toast.LENGTH_SHORT).show();

}

});
  • 5.属性
属性 解释
addtextcolor 加号文字颜色
addtextbg 加号背景
minustextcolor 减号文字颜色
minustextbg 减号背景
buttonwidth 加减号的按钮宽度
buttonheight 加减号按钮高度
textwidth 文字按钮宽度
textcolor 文字颜色
textbg 文字背景
alltextsize 所有按钮文字大小
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 174,540评论 25 709
  • Android组件化项目地址:Android组件化项目AndroidModulePattern Android组件...
    半灬边灬天阅读 2,963评论 4 37
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,258评论 19 139
  • 宜信全球 产品定位:金融理财产品电商平台 面向人群:对中,高端理财产品的需求者,具有一定的经济基础,对国际理财有认...
    超设计阅读 473评论 0 1
  • 毕业后离开学校,回到南方,一直没有一个理由回学校,手机里也只剩下这张学校的夜景。
    茕茕者阅读 107评论 0 0