亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 系統 > Android > 正文

Android實現美團下拉功能

2019-10-21 21:37:04
字體:
來源:轉載
供稿:網友

本文實例為大家分享了Android實現美團下拉功能的具體代碼,供大家參考,具體內容如下

效果圖

Android,美團下拉

實現

布局文件:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:layout_width="match_parent"  android:layout_height="match_parent"  android:background="#f0f0f0"  android:orientation="vertical" >  <FrameLayout    android:id="@+id/titlebar_layout"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:background="#5555" >    <RelativeLayout      android:layout_width="match_parent"      android:layout_height="50dp"      android:background="#ffffff"      android:gravity="center_vertical"      android:orientation="horizontal" >      <LinearLayout        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignParentLeft="true"        android:layout_centerVertical="true"        android:layout_marginLeft="5dp"        android:gravity="center_vertical" >        <ImageView          android:layout_width="25dp"          android:layout_height="25dp"          android:onClick="back"          android:src="@mipmap/icon_arrow_green" />        <TextView          android:id="@+id/supplier_list_title_tv"          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:layout_marginLeft="5dp"          android:text="全部"          android:textColor="#39ac69"          android:textSize="18dp" />      </LinearLayout>      <ImageView        android:id="@+id/supplier_list_cart_iv"        android:layout_width="25dp"        android:layout_height="25dp"        android:layout_alignParentRight="true"        android:layout_centerVertical="true"        android:layout_marginRight="15dp"        android:src="@mipmap/icon_car" />    </RelativeLayout>  </FrameLayout>  <View    android:layout_width="match_parent"    android:layout_height="1dp"    android:background="#E2E2E2" />  <LinearLayout    android:layout_width="match_parent"    android:layout_height="40dp"    android:background="#ffffff"    android:orientation="horizontal" >    <LinearLayout      android:id="@+id/supplier_list_product"      android:layout_width="0dp"      android:layout_height="match_parent"      android:layout_weight="1"      android:gravity="center"      android:orientation="horizontal" >      <TextView        android:id="@+id/supplier_list_product_tv"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:gravity="center"        android:text="全部"        android:textSize="14dp" />      <ImageView        android:layout_width="25dp"        android:layout_height="25dp"        android:src="@mipmap/icon_arrow_down" />    </LinearLayout>    <LinearLayout      android:id="@+id/supplier_list_sort"      android:layout_width="0dp"      android:layout_height="match_parent"      android:layout_weight="1"      android:gravity="center"      android:orientation="horizontal" >      <TextView        android:id="@+id/supplier_list_sort_tv"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:gravity="center"        android:text="綜合排序"        android:textSize="14dp" />      <ImageView        android:layout_width="25dp"        android:layout_height="25dp"        android:src="@mipmap/icon_arrow_down" />    </LinearLayout>    <LinearLayout      android:id="@+id/supplier_list_activity"      android:layout_width="0dp"      android:layout_height="match_parent"      android:layout_weight="1"      android:gravity="center"      android:orientation="horizontal" >      <TextView        android:id="@+id/supplier_list_activity_tv"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:gravity="center"        android:text="優惠活動"        android:textSize="14dp" />      <ImageView        android:layout_width="25dp"        android:layout_height="25dp"        android:src="@mipmap/icon_arrow_down" />    </LinearLayout>  </LinearLayout>  <View    android:layout_width="match_parent"    android:layout_height="0.5dp"    android:background="#E2E2E2" />  <RelativeLayout    android:layout_width="match_parent"    android:layout_height="match_parent" >    <ListView      android:id="@+id/supplier_list_lv"      android:layout_width="match_parent"      android:layout_height="match_parent"      android:layout_marginTop="10dp"      android:cacheColorHint="@android:color/transparent"      android:divider="#f0f0f0"      android:dividerHeight="10dp"      android:fadingEdge="none"      android:listSelector="#00000000"      android:scrollbarStyle="outsideOverlay"      android:scrollingCache="false" />    <ProgressBar      android:id="@+id/progress"      android:layout_width="wrap_content"      android:layout_height="wrap_content"      android:layout_centerInParent="true"      android:indeterminateDrawable="@drawable/shape_progress"      android:indeterminateDuration="1000" />  </RelativeLayout></LinearLayout>

 

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:layout_width="match_parent"  android:layout_height="wrap_content"  android:background="#ffffff"  android:orientation="vertical" >  <LinearLayout    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:gravity="center_vertical"    android:orientation="horizontal" >    <TextView      android:id="@+id/listview_popwind_tv"      android:layout_width="match_parent"      android:layout_height="45dp"      android:layout_marginLeft="15dp"      android:layout_marginRight="15dp"      android:gravity="center_vertical"      android:text="地點"      android:textColor="#5a5959"      android:textSize="18dp" />  </LinearLayout>  <View    android:layout_width="match_parent"    android:layout_height="1dp"    android:layout_marginLeft="15dp"    android:layout_marginRight="15dp"    android:background="#E2E2E2" /></LinearLayout>

 

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:layout_width="match_parent"  android:layout_height="match_parent"  android:background="#5000"  android:orientation="vertical" >  <ListView    android:id="@+id/popwin_supplier_list_lv"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:cacheColorHint="@android:color/transparent"    android:divider="#0000"    android:dividerHeight="0dp"    android:fadingEdge="none"    android:listSelector="#00000000"    android:scrollbarStyle="outsideOverlay"    android:scrollbars="none"    android:scrollingCache="false" />  <LinearLayout    android:id="@+id/popwin_supplier_list_bottom"    android:layout_width="match_parent"    android:layout_height="0dp"    android:layout_weight="1"    android:orientation="vertical" /></LinearLayout>

Activity代碼:

package com.example.hfs.popwindowmeituan;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;import android.app.Activity;import android.content.Intent;import android.graphics.Color;import android.graphics.drawable.BitmapDrawable;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.AdapterView;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.ListView;import android.widget.PopupWindow;import android.widget.ProgressBar;import android.widget.SimpleAdapter;import android.widget.TextView;import android.widget.Toast;import android.widget.AdapterView.OnItemClickListener;import android.widget.PopupWindow.OnDismissListener;public class MainActivity extends Activity implements    OnClickListener {  private ListView listView, popListView;  private ProgressBar progressBar;  private List<Map<String, String>> menuData1, menuData2, menuData3;  private PopupWindow popMenu;  private SimpleAdapter menuAdapter1, menuAdapter2, menuAdapter3;  private LinearLayout product, sort, activity;  private ImageView cartIv;  private TextView productTv, sortTv, activityTv, titleTv;  private int green, grey;  private String currentProduct, currentSort, currentActivity;  private int menuIndex = 0;  private Intent intent;  @Override  protected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_supplier_list);    findView();    initMenuData();    initPopMenu();  }  private void initMenuData() {    menuData1 = new ArrayList<Map<String, String>>();    String[] menuStr1 = new String[] { "全部", "糧油", "衣服", "圖書", "電子產品",        "酒水飲料", "水果" };    Map<String, String> map1;    for (int i = 0, len = menuStr1.length; i < len; ++i) {      map1 = new HashMap<String, String>();      map1.put("name", menuStr1[i]);      menuData1.add(map1);    }    menuData2 = new ArrayList<Map<String, String>>();    String[] menuStr2 = new String[] { "綜合排序", "配送費最低" };    Map<String, String> map2;    for (int i = 0, len = menuStr2.length; i < len; ++i) {      map2 = new HashMap<String, String>();      map2.put("name", menuStr2[i]);      menuData2.add(map2);    }    menuData3 = new ArrayList<Map<String, String>>();    String[] menuStr3 = new String[] { "優惠活動", "特價活動", "免配送費",        "可在線支付" };    Map<String, String> map3;    for (int i = 0, len = menuStr3.length; i < len; ++i) {      map3 = new HashMap<String, String>();      map3.put("name", menuStr3[i]);      menuData3.add(map3);    }  }  @Override  public void onClick(View v) {    // TODO Auto-generated method stub    switch (v.getId()) {      case R.id.supplier_list_product:        productTv.setTextColor(Color.parseColor("#39ac69"));        popListView.setAdapter(menuAdapter1);        popMenu.showAsDropDown(product, 0, 2);        menuIndex = 0;        break;      case R.id.supplier_list_sort:        sortTv.setTextColor(Color.parseColor("#39ac69"));        popListView.setAdapter(menuAdapter2);        popMenu.showAsDropDown(product, 0, 2);        menuIndex = 1;        break;      case R.id.supplier_list_activity:        activityTv.setTextColor(Color.parseColor("#39ac69"));        popListView.setAdapter(menuAdapter3);        popMenu.showAsDropDown(product, 0, 2);        menuIndex = 2;        break;    }  }  protected void findView() {    listView = (ListView) findViewById(R.id.supplier_list_lv);    product = (LinearLayout) findViewById(R.id.supplier_list_product);    sort = (LinearLayout) findViewById(R.id.supplier_list_sort);    activity = (LinearLayout) findViewById(R.id.supplier_list_activity);    productTv = (TextView) findViewById(R.id.supplier_list_product_tv);    sortTv = (TextView) findViewById(R.id.supplier_list_sort_tv);    activityTv = (TextView) findViewById(R.id.supplier_list_activity_tv);    titleTv = (TextView) findViewById(R.id.supplier_list_title_tv);    cartIv = (ImageView) findViewById(R.id.supplier_list_cart_iv);    progressBar = (ProgressBar) findViewById(R.id.progress);    product.setOnClickListener(this);    sort.setOnClickListener(this);    activity.setOnClickListener(this);    cartIv.setOnClickListener(this);  }  private void initPopMenu() {    initMenuData();    View contentView = View.inflate(this, R.layout.popwin_supplier_list,        null);    popMenu = new PopupWindow(contentView,        LinearLayout.LayoutParams.MATCH_PARENT,        LinearLayout.LayoutParams.MATCH_PARENT);    popMenu.setOutsideTouchable(true);    popMenu.setBackgroundDrawable(new BitmapDrawable());    popMenu.setFocusable(true);    popMenu.setAnimationStyle(R.style.popwin_anim_style);    popMenu.setOnDismissListener(new OnDismissListener() {      public void onDismiss() {        productTv.setTextColor(Color.parseColor("#5a5959"));        sortTv.setTextColor(Color.parseColor("#5a5959"));        activityTv.setTextColor(Color.parseColor("#5a5959"));      }    });    popListView = (ListView) contentView        .findViewById(R.id.popwin_supplier_list_lv);    contentView.findViewById(R.id.popwin_supplier_list_bottom)        .setOnClickListener(new OnClickListener() {          public void onClick(View arg0) {            popMenu.dismiss();          }        });    menuAdapter1 = new SimpleAdapter(this, menuData1,        R.layout.item_listview_popwin, new String[] { "name" },        new int[] { R.id.listview_popwind_tv });    menuAdapter2 = new SimpleAdapter(this, menuData2,        R.layout.item_listview_popwin, new String[] { "name" },        new int[] { R.id.listview_popwind_tv });    menuAdapter3 = new SimpleAdapter(this, menuData3,        R.layout.item_listview_popwin, new String[] { "name" },        new int[] { R.id.listview_popwind_tv });    popListView.setOnItemClickListener(new OnItemClickListener() {      public void onItemClick(AdapterView<?> arg0, View arg1, int pos,                  long arg3) {        popMenu.dismiss();        if (menuIndex == 0) {          currentProduct = menuData1.get(pos).get("name");          titleTv.setText(currentProduct);          productTv.setText(currentProduct);          Toast.makeText(MainActivity.this, currentProduct, Toast.LENGTH_SHORT).show();        } else if (menuIndex == 1) {          currentSort = menuData2.get(pos).get("name");          titleTv.setText(currentSort);          sortTv.setText(currentSort);          Toast.makeText(MainActivity.this, currentSort, Toast.LENGTH_SHORT).show();        } else {          currentActivity = menuData3.get(pos).get("name");          titleTv.setText(currentActivity);          activityTv.setText(currentActivity);          Toast.makeText(MainActivity.this, currentActivity, Toast.LENGTH_SHORT).show();        }      }    });  }}

其實和我博客里面有一篇自定義Spinner很像 

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到Android開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
亚洲一区二区三区久久| 2019中文字幕在线| www国产精品视频| 亚洲成人激情在线| 欧美自拍视频在线| 成人黄色片在线| 亚洲第一av在线| 国内精品久久影院| 中文字幕亚洲在线| 亚洲一区亚洲二区| 色悠悠久久88| 国产精品久久久久久久久久免费| 国产精品吹潮在线观看| 欧美中文字幕视频| 国产女人18毛片水18精品| 亚洲欧洲日产国码av系列天堂| 久久免费观看视频| 国产精品h片在线播放| 亚洲高清一区二| 日韩免费黄色av| 精品中文字幕视频| 亚洲精品一区二区三区不| 伊人成人开心激情综合网| 日韩欧美一区二区三区久久| 最近2019中文字幕在线高清| 成人xvideos免费视频| 亚洲黄色在线看| 国产精品老女人精品视频| 久久在线观看视频| 精品久久久久久国产| 国产亚洲欧洲高清| 亚洲欧美一区二区三区久久| 亚洲综合自拍一区| 亚洲自拍偷拍视频| 亚洲视频欧洲视频| 中文字幕欧美精品日韩中文字幕| 久久精品国产欧美亚洲人人爽| 日韩av在线一区| 国产精品成人v| 久久精品91久久香蕉加勒比| 自拍偷拍亚洲欧美| 久久影院模特热| 永久免费看mv网站入口亚洲| 日韩一区二区三区国产| 国产欧美韩国高清| 亚洲欧美日韩爽爽影院| 91精品国产91久久久久久吃药| 亚洲成年人影院在线| 日韩精品免费看| 中文字幕日韩有码| 亚洲国产精久久久久久久| 精品中文字幕视频| 91精品国产高清自在线看超| 日韩电视剧在线观看免费网站| 欧美国产日韩xxxxx| 在线播放国产一区二区三区| 国产精品无av码在线观看| 国产精品日韩av| 亚洲欧美综合区自拍另类| 久久香蕉频线观| 国内精品久久久久久中文字幕| 精品国内亚洲在观看18黄| 欧美性猛交99久久久久99按摩| 草民午夜欧美限制a级福利片| 国产视频在线观看一区二区| 国产成人jvid在线播放| 日韩在线观看免费高清完整版| 久久精品中文字幕免费mv| 久久精品男人天堂| 91手机视频在线观看| 日韩免费av片在线观看| 久久天天躁狠狠躁夜夜躁2014| 最近中文字幕mv在线一区二区三区四区| 亚洲精品一区中文字幕乱码| 中文国产成人精品久久一| 国产欧美va欧美va香蕉在线| 国产一区二区三区高清在线观看| 尤物yw午夜国产精品视频明星| 国产精品美女呻吟| 亚洲欧美日韩国产中文专区| 九九热精品视频国产| 超碰97人人做人人爱少妇| 中文字幕日韩在线播放| 精品一区二区三区四区| 日韩成人在线视频网站| 91国偷自产一区二区三区的观看方式| 97视频国产在线| 精品自拍视频在线观看| 91色琪琪电影亚洲精品久久| 九九久久久久99精品| 欧美激情第一页xxx| 午夜精品一区二区三区在线| 欧美尤物巨大精品爽| 色先锋资源久久综合5566| 中文字幕在线日韩| 中文字幕日韩在线观看| 亚洲va男人天堂| 国模精品一区二区三区色天香| 97久久超碰福利国产精品…| 久久久999精品视频| 欧美一级在线亚洲天堂| 欧美人交a欧美精品| 国产日韩av在线播放| 中文字幕欧美视频在线| 国产福利视频一区二区| 日韩精品在线免费观看视频| 欧美激情一区二区三区在线视频观看| 日韩亚洲第一页| xvideos亚洲| 国产精品老牛影院在线观看| 国产精品日日摸夜夜添夜夜av| 色av吧综合网| 国产精品视频最多的网站| 久久久久久久久中文字幕| 欧美性猛交xxxx免费看| 在线观看精品国产视频| 成人在线视频福利| 日韩av不卡在线| 91亚洲午夜在线| 日韩在线视频国产| 在线观看欧美日韩| 不卡在线观看电视剧完整版| 欧美性xxxx极品hd欧美风情| 中文字幕精品一区二区精品| 亚洲伊人久久大香线蕉av| 国产日产欧美a一级在线| 国产日韩中文在线| 精品久久久久久久久久久| 国产一区二区免费| 国产成人精品亚洲精品| 欧美日韩国产精品一区二区不卡中文| 欧美性猛交xxxx乱大交3| 国产精品成人免费视频| 亚洲成人精品在线| 国产精品午夜视频| 国产成人免费av| 91国产高清在线| 国产视频精品自拍| 欧美极度另类性三渗透| 亚洲男人7777| 国产精品久久久一区| 精品久久久久久久久久久久久| 国产精品午夜一区二区欲梦| 26uuu日韩精品一区二区| 日韩在线观看免费高清完整版| 久久久久中文字幕2018| 日韩欧美国产视频| 欧美在线视频网站| 亚洲图片在线综合| 日本成人精品在线| 久久夜色精品国产| 欧美精品一区二区三区国产精品| 欧美日韩国产区| 在线观看成人黄色| 国产精品自拍偷拍视频| 中文字幕欧美精品日韩中文字幕| 欧美精品午夜视频| 亚洲精品电影网| 最近日韩中文字幕中文| 在线观看中文字幕亚洲| 亚洲欧美日韩一区在线| 国产91精品视频在线观看| 91精品久久久久久久久青青| 欧美国产极速在线|