成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

android如何實(shí)現(xiàn)仿京東商品屬性篩選功能-創(chuàng)新互聯(lián)

這篇文章將為大家詳細(xì)講解有關(guān)android如何實(shí)現(xiàn)仿京東商品屬性篩選功能,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

目前成都創(chuàng)新互聯(lián)公司已為上千家的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)站空間、網(wǎng)站托管、企業(yè)網(wǎng)站設(shè)計(jì)、興縣網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。

篩選和屬性選擇是目前非常常用的功能模塊;幾乎所有的APP中都會(huì)使用;

android如何實(shí)現(xiàn)仿京東商品屬性篩選功能

點(diǎn)擊篩選按鈕會(huì)彈出一個(gè)自己封裝好的popupWindow,實(shí)用方法非常簡(jiǎn)單;兩行代碼直接顯示;(當(dāng)然初始化數(shù)據(jù)除外)

這里和以前用到的流式布局有些不一樣:流式布局

以前使用的是單個(gè)分類,而且也沒(méi)有在項(xiàng)目中大量實(shí)用;這個(gè)篩選功能除了數(shù)據(jù)外幾乎都是從項(xiàng)目中Copy出來(lái)的;

整個(gè)popupWindow布局就是一個(gè)自定義的ListView,這個(gè)自定義的listview主要是控制listview的高度;

如果數(shù)據(jù)少的話就是自適應(yīng),如果數(shù)據(jù)多了就限制高度為屏幕的一半;

自定義的ListView:

public class CustomHeightListView extends ListView { 
 
  private Context mContext; 
 
  public CustomHeightListView(Context context) { 
    this(context, null); 
  } 
 
  public CustomHeightListView(Context context, AttributeSet attrs) { 
    this(context, attrs, 0); 
  } 
 
  public CustomHeightListView(Context context, AttributeSet attrs, int defStyleAttr) { 
    super(context, attrs, defStyleAttr); 
    init(context); 
  } 
 
  private void init(Context context) { 
    mContext = context; 
  } 
 
  @Override 
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 
    try { 
      //大高度顯示為屏幕內(nèi)容高度的一半 
      Display display = ((Activity) mContext).getWindowManager().getDefaultDisplay(); 
      DisplayMetrics d = new DisplayMetrics(); 
      display.getMetrics(d); 
      //設(shè)置控件高度不能超過(guò)屏幕高度一半(d.heightPixels / 2,下面有清空按鈕所以再減200,也可隨意換成自己想要的高度) 
      heightMeasureSpec = MeasureSpec.makeMeasureSpec(d.heightPixels / 2 - 200, MeasureSpec.AT_MOST); 
    } catch (Exception e) { 
      e.printStackTrace(); 
    } 
    //重新計(jì)算控件高、寬 
    super.onMeasure(widthMeasureSpec, heightMeasureSpec); 
  } 
}

ListView中每個(gè)item是一個(gè)流式布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  android:layout_width="match_parent" 
  android:layout_height="wrap_content" 
  android:orientation="vertical"> 
 
  <TextView 
    android:id="@+id/tv_type_name" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" /> 
 
  <com.example.zheng.flowlayoutdemo.view.SkuFlowLayout 
    android:id="@+id/layout_property" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" /> 
   
</LinearLayout>

整個(gè)popupwindow都封裝在一個(gè)類中,創(chuàng)建的時(shí)候只需把數(shù)據(jù)源傳遞過(guò)去即可,實(shí)用的時(shí)候直接show就可以了

flowPopWindow = new FlowPopWindow(MainActivity.this, dictList); 
    flowPopWindow.showAsDropDown(ivBack);

當(dāng)點(diǎn)擊確定的時(shí)候直接設(shè)置一個(gè)監(jiān)聽(tīng)即可:

flowPopWindow.setOnConfirmClickListener(new FlowPopWindow.OnConfirmClickListener() { 
     @Override 
     public void onConfirmClick() { 
      StringBuilder sb = new StringBuilder(); 
      for (FiltrateBean fb : dictList) { 
       List<FiltrateBean.Children> cdList = fb.getChildren(); 
       for (int x = 0; x < cdList.size(); x++) { 
        FiltrateBean.Children children = cdList.get(x); 
        if (children.isSelected()) 
         sb.append(fb.getTypeName() + ":" + children.getValue() + ";"); 
       } 
      } 
      if (!TextUtils.isEmpty(sb.toString())) 
       Toast.makeText(MainActivity.this, sb.toString(), Toast.LENGTH_LONG).show(); 
     } 
    }

關(guān)于“android如何實(shí)現(xiàn)仿京東商品屬性篩選功能”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。

網(wǎng)站標(biāo)題:android如何實(shí)現(xiàn)仿京東商品屬性篩選功能-創(chuàng)新互聯(lián)
鏈接地址:http://jinyejixie.com/article8/ddchip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化定制網(wǎng)站、軟件開(kāi)發(fā)、移動(dòng)網(wǎng)站建設(shè)搜索引擎優(yōu)化、全網(wǎng)營(yíng)銷推廣

廣告

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

外貿(mào)網(wǎng)站建設(shè)
罗田县| 双牌县| 如东县| 邻水| 金湖县| 盐津县| 涿鹿县| 卢龙县| 汶上县| 栖霞市| 曲沃县| 容城县| 东乡族自治县| 额尔古纳市| 罗江县| 南雄市| 上思县| 宾阳县| 江山市| 阿拉善左旗| 和静县| 漳浦县| 葵青区| 马山县| 拉萨市| 太仓市| 修武县| 奎屯市| 保德县| 资兴市| 五家渠市| 额尔古纳市| 汽车| 南康市| 宜宾市| 宜州市| 武宣县| 凤凰县| 高唐县| 龙游县| 丹凤县|