1.先來張效果圖
創(chuàng)新互聯(lián)公司堅持“要么做到,要么別承諾”的工作理念,服務領域包括:網(wǎng)站制作、成都做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣等服務,滿足客戶于互聯(lián)網(wǎng)時代的金安網(wǎng)站設計、移動媒體設計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡建設合作伙伴!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://bm7419.com/article4/ddpeie.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導航、品牌網(wǎng)站設計、網(wǎng)站維護、靜態(tài)網(wǎng)站、網(wǎng)站內鏈、云服務器
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內容