Android實現(xiàn)購物車及其他功能的角標-創(chuàng)新互聯(lián)

1.先來張效果圖

創(chuàng)新互聯(lián)公司堅持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站制作、成都做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時代的金安網(wǎng)站設(shè)計、移動媒體設(shè)計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

2.自定義一個角標工具類BottomBarView 。

**
 * Created by Administrator on 2016/12/27.
 * 角標工具類
 */
public class BottomBarView extends RelativeLayout {
 private Context context;
 private TextView bar_num;
 private int count = 0;
 public BottomBarView(Context context) {
 this(context, null);
 }
 public BottomBarView(Context context, AttributeSet attrs) {
 this(context, attrs, 0);
 }
 public BottomBarView(Context context, AttributeSet attrs, int defStyleAttr) {
 super(context, attrs, defStyleAttr);
 this.context = context;
 RelativeLayout rl = (RelativeLayout) LayoutInflater.from(context).inflate(R.layout.bottom_bar_view, this, true);
 bar_num = (TextView) rl.findViewById(R.id.bar_num);
 bar_num.setVisibility(GONE);
 }
 public void add() {
 bar_num.setVisibility(VISIBLE);
 count++;
 if (count < 100) {
 bar_num.setText(count + "");
 } else {
 bar_num.setText("99+");
 }
 }
 public void add(int n) throws Exception {
 if(n<0){
 throw new Exception(BottomBarView.class.getSimpleName()+" add(int n).The param must be a positive num");
 }
 bar_num.setVisibility(VISIBLE);
 count += n;
 if (count < 100) {
 bar_num.setText(count + "");
 } else {
 bar_num.setText("99+");
 }
 }
 public void delete() {
 if (count == 0) {
 bar_num.setVisibility(GONE);
 } else {
 count--;
 if (count == 0) {
 bar_num.setVisibility(GONE);
 } else if (count > 0 && count < 100) {
 bar_num.setVisibility(VISIBLE);
 bar_num.setText(count + "");
 } else {
 bar_num.setVisibility(VISIBLE);
 bar_num.setText("99+");
 }
 }
 }
 public void deleteAll() {
 count = 0;
 bar_num.setVisibility(GONE);
 }
}

本文題目:Android實現(xiàn)購物車及其他功能的角標-創(chuàng)新互聯(lián)
文章分享:http://muchs.cn/article4/ddpeie.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、品牌網(wǎng)站設(shè)計網(wǎng)站維護、靜態(tài)網(wǎng)站網(wǎng)站內(nèi)鏈、云服務(wù)器

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管