精华内容
下载资源
问答
  • jQuery多级下拉菜单支持多级下拉列表菜单代码 jQuery多级下拉菜单支持多级下拉列表菜单代码 jQuery多级下拉菜单支持多级下拉列表菜单代码
  • jQuery多级下拉菜单支持多级下拉列表菜单,适用于商城网站或者企业网站,php中文网推荐下载!
  • jQuery多级下拉菜单支持多级下拉列表菜单代码。
  • Excel 多级下拉列表例子 用于在Excel中创建三级下拉列表。
  • 多级下拉列表选择处理

    千次阅读 2016-05-27 16:58:45
    多级下拉列表选择,总布局采用相对布局,设置listView的隐藏与显示来实现多级下拉列表的功能,并且需要选项之间有联动性

    public class MainActivity extends Activity {
    private Context context;
    private ListView mListView, mShoplist_threelist, mShoplist_onelist2,
    mShoplist_twolist2, mShoplist_onelist1, mShoplist_twolist1;
    private LinearLayout mShoplist_mainlist2, mShoplist_mainlist1;


    private TextView mShoplist_title_textbtn1, mShoplist_title_textbtn2,
    mShoplist_title_textbtn3;

    private SearchMoreAdapter threeadapter = null;
    private SearchMoreAdapter twoadapter1 = null;
    private SearchMainAdapter oneadapter1 = null;
    private SearchMoreAdapter twoadapter2 = null;
    private SearchMainAdapter oneadapter2 = null;

    private boolean threelistview = false;
    private boolean mainlistview1 = false;
    private boolean mainlistview2 = false;

    private List<Map<String, Object>> mainList1;
    private List<Map<String, Object>> mainList2;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initView();
    context=this;
    setpagedata();


    }












    private void setpagedata() {
    // TODO Auto-generated method stub
    initModel1();
    initModel2();
    oneadapter1 = new SearchMainAdapter(context, mainList1,R.layout.shop_list1_item,false);
    oneadapter1.setSelectItem(0);
    mShoplist_onelist1.setAdapter(oneadapter1);
    oneadapter2 = new SearchMainAdapter(context, mainList2,R.layout.shop_list1_item,true);
    oneadapter2.setSelectItem(0);
    mShoplist_onelist2.setAdapter(oneadapter2);
    threeadapter = new SearchMoreAdapter(context,Model.SHOPLIST_THREELIST,R.layout.shop_list2_item);
    mShoplist_threelist.setAdapter(threeadapter);

    initAdapter1(Model.SHOPLIST_PLACESTREET[0]);
    initAdapter2(Model.MORELISTTXT[0]);

    Onelistclick1 onelistclick1 = new Onelistclick1();
    Twolistclick1 twolistclick1 = new Twolistclick1();
    Onelistclick2 onelistclick2 = new Onelistclick2();
    Twolistclick2 twolistclick2 = new Twolistclick2();
    ThreeListOnItemclick threeListOnItemClick = new ThreeListOnItemclick();

    mShoplist_onelist1.setOnItemClickListener(onelistclick1);
    mShoplist_twolist1.setOnItemClickListener(twolistclick1);
    mShoplist_onelist2.setOnItemClickListener(onelistclick2);
    mShoplist_twolist2.setOnItemClickListener(twolistclick2);
    mShoplist_threelist.setOnItemClickListener(threeListOnItemClick);



    }




    private void initModel1() {
    mainList1 = new ArrayList<Map<String, Object>>();
    for (int i = 0; i < Model.SHOPLIST_PLACE.length; i++) {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("txt", Model.SHOPLIST_PLACE[i]);
    mainList1.add(map);
    }
    }
    private void initModel2() {
    mainList2 = new ArrayList<Map<String, Object>>();
    for (int i = 0; i < Model.LISTVIEWTXT.length; i++) {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("img", Model.LISTVIEWIMG[i]);
    map.put("txt", Model.LISTVIEWTXT[i]);
    mainList2.add(map);
    }
    }




    private void initAdapter1(String[] array) {
    twoadapter1 = new SearchMoreAdapter(context, array,R.layout.shop_list2_item);
    mShoplist_twolist1.setAdapter(twoadapter1);
    twoadapter1.notifyDataSetChanged();
    }


    private void initAdapter2(String[] array) {
    twoadapter2 = new SearchMoreAdapter(context, array,R.layout.shop_list2_item);
    mShoplist_twolist2.setAdapter(twoadapter2);
    twoadapter2.notifyDataSetChanged();
    }




    private void initView() {
    // TODO Auto-generated method stub
    mShoplist_title_textbtn1 = (TextView) findViewById(R.id.Shoplist_title_textbtn1);
    mShoplist_title_textbtn2 = (TextView) findViewById(R.id.Shoplist_title_textbtn2);
    mShoplist_title_textbtn3 = (TextView) findViewById(R.id.Shoplist_title_textbtn3);

    mShoplist_mainlist1 = (LinearLayout) findViewById(R.id.Shoplist_mainlist1);
    mShoplist_mainlist2 = (LinearLayout) findViewById(R.id.Shoplist_mainlist2);
    mShoplist_onelist1 = (ListView) findViewById(R.id.Shoplist_onelist1);
    mShoplist_twolist1 = (ListView) findViewById(R.id.Shoplist_twolist1);
    mShoplist_onelist2 = (ListView) findViewById(R.id.Shoplist_onelist2);
    mShoplist_twolist2 = (ListView) findViewById(R.id.Shoplist_twolist2);
    mShoplist_threelist = (ListView) findViewById(R.id.Shoplist_threelist);

    MyOnclickListener mOnclickListener = new MyOnclickListener();
    mShoplist_title_textbtn1.setOnClickListener(mOnclickListener);
    mShoplist_title_textbtn2.setOnClickListener(mOnclickListener);
    mShoplist_title_textbtn3.setOnClickListener(mOnclickListener);





    }


    private class Onelistclick1 implements OnItemClickListener {
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
    long arg3) {
    initAdapter1(Model.SHOPLIST_PLACESTREET[arg2]);
    oneadapter1.setSelectItem(arg2);
    oneadapter1.notifyDataSetChanged();
    }
    }


    private class Twolistclick1 implements OnItemClickListener {
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
    long arg3) {
    twoadapter1.setSelectItem(arg2);
    Drawable drawable = getResources().getDrawable(
    R.drawable.ic_arrow_down_black);
    drawable.setBounds(0, 0, drawable.getMinimumWidth(),
    drawable.getMinimumHeight());
    mShoplist_title_textbtn1.setCompoundDrawables(null, null, drawable,
    null);
    int position = oneadapter1.getSelectItem();
    mShoplist_title_textbtn1
    .setText(Model.SHOPLIST_PLACESTREET[position][arg2]);
    mShoplist_mainlist1.setVisibility(View.GONE);
    mainlistview1 = false;
    }
    }


    private class Onelistclick2 implements OnItemClickListener {
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
    long arg3) {
    initAdapter2(Model.MORELISTTXT[arg2]);
    oneadapter2.setSelectItem(arg2);
    oneadapter2.notifyDataSetChanged();
    }
    }


    private class Twolistclick2 implements OnItemClickListener {
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
    long arg3) {
    twoadapter2.setSelectItem(arg2);
    Drawable drawable = getResources().getDrawable(
    R.drawable.ic_arrow_down_black);
    drawable.setBounds(0, 0, drawable.getMinimumWidth(),
    drawable.getMinimumHeight());
    mShoplist_title_textbtn2.setCompoundDrawables(null, null, drawable,
    null);
    int position = oneadapter2.getSelectItem();
    mShoplist_title_textbtn2.setText(Model.MORELISTTXT[position][arg2]);
    mShoplist_mainlist2.setVisibility(View.GONE);
    mainlistview2 = false;
    }
    }

    private class ThreeListOnItemclick implements OnItemClickListener {
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
    long arg3) {
    threeadapter.setSelectItem(arg2);
    Drawable drawable = getResources().getDrawable(
    R.drawable.ic_arrow_down_black);
    drawable.setBounds(0, 0, drawable.getMinimumWidth(),
    drawable.getMinimumHeight());
    mShoplist_title_textbtn3.setCompoundDrawables(null, null, drawable,
    null);
    mShoplist_title_textbtn3.setText(Model.SHOPLIST_THREELIST[arg2]);
    mShoplist_threelist.setVisibility(View.GONE);
    threelistview = false;
    }
    }

    private class MyOnclickListener implements View.OnClickListener {
    public void onClick(View v) {
    int mID = v.getId();
    if (mID == R.id.Shoplist_title_textbtn3) {
    Drawable drawable = null;
    if (!threelistview) {
    drawable = getResources().getDrawable(
    R.drawable.ic_arrow_up_black);
    mShoplist_threelist.setVisibility(View.VISIBLE);
    threeadapter.notifyDataSetChanged();
    threelistview = true;
    } else {
    drawable = getResources().getDrawable(
    R.drawable.ic_arrow_down_black);
    mShoplist_threelist.setVisibility(View.GONE);
    threelistview = false;
    }
    // 这一步必须要做,否则不会显示.
    drawable.setBounds(0, 0, drawable.getMinimumWidth(),
    drawable.getMinimumHeight());
    mShoplist_title_textbtn3.setCompoundDrawables(null, null,
    drawable, null);
    } else {
    Drawable drawable = getResources().getDrawable(
    R.drawable.ic_arrow_down_black);
    drawable.setBounds(0, 0, drawable.getMinimumWidth(),
    drawable.getMinimumHeight());
    mShoplist_title_textbtn3.setCompoundDrawables(null, null,
    drawable, null);
    mShoplist_threelist.setVisibility(View.GONE);
    threelistview = false;


    }
    if (mID == R.id.Shoplist_title_textbtn2) {
    Drawable drawable = null;
    if (!mainlistview2) {
    drawable = getResources().getDrawable(
    R.drawable.ic_arrow_up_black);
    mShoplist_mainlist2.setVisibility(View.VISIBLE);
    twoadapter2.notifyDataSetChanged();
    mainlistview2 = true;
    } else {
    drawable = getResources().getDrawable(
    R.drawable.ic_arrow_down_black);
    mShoplist_mainlist2.setVisibility(View.GONE);
    mainlistview2 = false;
    }
    // 这一步必须要做,否则不会显示.
    drawable.setBounds(0, 0, drawable.getMinimumWidth(),
    drawable.getMinimumHeight());
    mShoplist_title_textbtn2.setCompoundDrawables(null, null,
    drawable, null);
    } else {
    Drawable drawable = getResources().getDrawable(
    R.drawable.ic_arrow_down_black);
    drawable.setBounds(0, 0, drawable.getMinimumWidth(),
    drawable.getMinimumHeight());
    mShoplist_title_textbtn2.setCompoundDrawables(null, null,
    drawable, null);
    mShoplist_mainlist2.setVisibility(View.GONE);
    mainlistview2 = false;
    }
    if (mID == R.id.Shoplist_title_textbtn1) {
    Drawable drawable = null;
    if (!mainlistview1) {
    drawable = getResources().getDrawable(
    R.drawable.ic_arrow_up_black);
    mShoplist_mainlist1.setVisibility(View.VISIBLE);
    twoadapter1.notifyDataSetChanged();
    mainlistview1 = true;
    } else {
    drawable = getResources().getDrawable(
    R.drawable.ic_arrow_down_black);
    mShoplist_mainlist1.setVisibility(View.GONE);
    mainlistview1 = false;
    }
    // 这一步必须要做,否则不会显示.
    drawable.setBounds(0, 0, drawable.getMinimumWidth(),
    drawable.getMinimumHeight());
    mShoplist_title_textbtn1.setCompoundDrawables(null, null,
    drawable, null);
    } else {
    Drawable drawable = getResources().getDrawable(
    R.drawable.ic_arrow_down_black);
    drawable.setBounds(0, 0, drawable.getMinimumWidth(),
    drawable.getMinimumHeight());
    mShoplist_title_textbtn1.setCompoundDrawables(null, null,
    drawable, null);
    mShoplist_mainlist1.setVisibility(View.GONE);
    mainlistview1 = false;
    }
    }
    }



    public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
    if (threelistview == true) {


    Drawable drawable = getResources().getDrawable(
    R.drawable.ic_arrow_down_black);
    drawable.setBounds(0, 0, drawable.getMinimumWidth(),
    drawable.getMinimumHeight());
    mShoplist_title_textbtn3.setCompoundDrawables(null, null,
    drawable, null);
    mShoplist_threelist.setVisibility(View.GONE);
    threelistview = false;
    } else if (mainlistview1 == true) {
    Drawable drawable = getResources().getDrawable(
    R.drawable.ic_arrow_down_black);
    drawable.setBounds(0, 0, drawable.getMinimumWidth(),
    drawable.getMinimumHeight());
    mShoplist_title_textbtn1.setCompoundDrawables(null, null,
    drawable, null);
    mShoplist_mainlist1.setVisibility(View.GONE);
    mainlistview1 = false;
    } else if (mainlistview2 == true) {
    Drawable drawable = getResources().getDrawable(
    R.drawable.ic_arrow_down_black);
    drawable.setBounds(0, 0, drawable.getMinimumWidth(),
    drawable.getMinimumHeight());
    mShoplist_title_textbtn2.setCompoundDrawables(null, null,
    drawable, null);
    mShoplist_mainlist2.setVisibility(View.GONE);
    mainlistview2 = false;
    } else {
    finish();
    }
    }
    return false;
    }


    }


    xml布局文件为:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >


        <RelativeLayout
            android:id="@+id/titlerelativelayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/title_background"
            android:gravity="center_vertical" >


            <ImageView
                android:id="@+id/Shoplist_back"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:paddingLeft="10dp"
                android:src="@drawable/ic_back_u" />


            <LinearLayout
                android:id="@+id/Shoplist_shanghuleixing"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:padding="10dp" >


                <TextView
                    android:id="@+id/Shoplist_title_txt"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center_vertical"
                    android:text="全部商户"
                    android:textColor="#FF8C00"
                    android:textSize="18sp" />
                <ImageView
                    android:id="@+id/Search_city_img"
                    android:layout_width="22dp"
                    android:layout_height="22dp"
                    android:src="@drawable/title_arrow_down_normal" />
            </LinearLayout>
        </RelativeLayout>
        <LinearLayout
            android:id="@+id/middlelinearlayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/titlerelativelayout" >
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@drawable/tuan_tab_linear_background"
                android:paddingBottom="0.5dp"
                android:paddingLeft="0dp"
                android:paddingRight="0.5dp"
                android:paddingTop="0dp" >


                <TextView
                    android:id="@+id/Shoplist_title_textbtn1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/my_tab_background"
                    android:drawableRight="@drawable/ic_arrow_down_black"
                    android:gravity="center_horizontal"
                    android:padding="10dp"
                    android:singleLine="true"
                    android:text="全部地区"
                    android:textColor="#666666" />
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@drawable/tuan_tab_linear_background"
                android:paddingBottom="0.5dp"
                android:paddingLeft="0dp"
                android:paddingRight="0.5dp"
                android:paddingTop="0dp" >
                <TextView
                    android:id="@+id/Shoplist_title_textbtn2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/my_tab_background"
                    android:drawableRight="@drawable/ic_arrow_down_black"
                    android:gravity="center_horizontal"
                    android:padding="10dp"
                    android:singleLine="true"
                    android:text="美食"
                    android:textColor="#666666" />
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@drawable/tuan_tab_linear_background"
                android:paddingBottom="0.5dp"
                android:paddingLeft="0dp"
                android:paddingRight="0.5dp"
                android:paddingTop="0dp" >
                <TextView
                    android:id="@+id/Shoplist_title_textbtn3"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/my_tab_background"
                    android:drawableRight="@drawable/ic_arrow_down_black"
                    android:gravity="center_horizontal"
                    android:padding="10dp"
                    android:singleLine="true"
                    android:text="默认排序"
                    android:textColor="#666666" />
            </LinearLayout>
        </LinearLayout> 
        <ListView
            android:id="@+id/ShopListView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/middlelinearlayout" />
        <ListView
            android:id="@+id/Shoplist_threelist"
            android:layout_width="match_parent"
            android:layout_height="350dp"
            android:layout_below="@+id/middlelinearlayout"
            android:background="#ffffff"
            android:divider="@null"
            android:listSelector="@android:color/transparent"
            android:padding="3dp"
            android:visibility="gone" />
        <LinearLayout
            android:id="@+id/Shoplist_mainlist2"
            android:layout_width="match_parent"
            android:layout_height="350dp"
            android:layout_below="@+id/middlelinearlayout"
            android:orientation="horizontal"
            android:visibility="gone" >
            <ListView
                android:id="@+id/Shoplist_onelist2"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="20"
                android:background="#F4F4F4"
                android:divider="@null"
                android:listSelector="@android:color/transparent"
                android:scrollbars="none" />
            <ListView
                android:id="@+id/Shoplist_twolist2"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="17"
                android:background="#FFFFFF"
                android:divider="@null"
                android:listSelector="@android:color/transparent" />
        </LinearLayout>
        <LinearLayout
            android:id="@+id/Shoplist_mainlist1"
            android:layout_width="match_parent"
            android:layout_height="350dp"
            android:layout_below="@+id/middlelinearlayout"
            android:orientation="horizontal"
            android:visibility="gone" >
            <ListView
                android:id="@+id/Shoplist_onelist1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="20"
                android:background="#F4F4F4"
                android:divider="@null"
                android:listSelector="@android:color/transparent"
                android:scrollbars="none" />


            <ListView
                android:id="@+id/Shoplist_twolist1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="17"
                android:background="#FFFFFF"
                android:divider="@null"
                android:listSelector="@android:color/transparent" />
        </LinearLayout>
    </RelativeLayout>


    public class Model {


    public static int[] LISTVIEWIMG = new int[] {
    R.drawable.ic_category_2147483648, R.drawable.ic_category_10,
    R.drawable.ic_category_20, R.drawable.ic_category_30,
    R.drawable.ic_category_45, R.drawable.ic_category_50,
    R.drawable.ic_category_55, R.drawable.ic_category_60,
    R.drawable.ic_category_65, R.drawable.ic_category_70,
    R.drawable.ic_category_80, R.drawable.ic_category_none };
    // 第一个listview的文本数据数组
    public static String[] LISTVIEWTXT = new String[] { "热门分类", "美食", "购物",
    "休闲娱乐", "运动健身", "丽人", "结婚", "酒店", "爱车", "亲子", "生活服务", "家装" };
    // 第二个listview的文本数据
    public static String[][] MORELISTTXT = {
    { "全部分类", "小吃快餐", "咖啡厅", "电影院", "KTV", "茶馆", "足疗按摩", "超市/便利店",
    "银行", "经济型酒店", "景点/郊游", "公园", "美发" },
    { "全部美食", "小吃快餐", "西餐", "火锅", "北京菜", "川菜", "日本", "面包甜点", "粤菜",
    "韩国料理", "自助餐", "浙江菜", "云南菜", "湘菜", "东南亚菜", "西北菜", "鲁菜",
    "东北菜", "素菜", "新疆菜", "海鲜", "清真菜", "贵州菜", "湖北菜", "其他" },
    { "全部购物", "综合商场", "服饰鞋包", "超市", "特色集市", "品牌折扣店", "眼镜店", "珠宝饰品",
    "化妆品", "运动户外", "食品茶酒", "书店", "数码产品", "药店", "京味儿购物", "亲子购物",
    "花店", "家具建材", "更多购物场所" },
    { "全部休闲娱乐", "咖啡厅", "KTV", "景点/郊游", "电影院", "酒吧", "公园", "温泉", "文化艺术",
    "足疗按摩", "洗浴", "茶馆", "游乐游艺", "密室", "农家乐", "桌面游戏", "台球馆",
    "DIY手工坊", "休闲网吧", "真人CS", "棋牌室", "轰趴馆", "私人影院", "更多休闲娱乐" },
    { "全部运动健身", "健身中心", "游泳馆", "瑜伽", "羽毛球馆", "台球馆", "舞蹈", "体育场馆",
    "高尔夫场", "网球场", "武术场馆", "篮球场", "保龄球馆", "足球场", "乒乓球馆",
    "更多体育运动" },
    { "全部丽人", "美发", "美容/SPA", "齿科", "美甲", "化妆品", "瑜伽", "瘦身纤体", "舞蹈",
    "个性写真", "整形" },
    { "全部结婚", "婚纱摄影", "婚宴酒店", "婚纱礼服", "婚庆公司", "婚戒首饰", "个性写真", "彩妆造型",
    "婚礼小礼品", "婚礼跟拍", "婚车租赁", "司仪主持", "婚房装修", "更多婚礼服务" },
    { "全部酒店", "经济型酒店", "五星级酒店", "度假村", "四星级酒店", "三星级酒店", "农家院",
    "公寓式酒店", "青年旅社", "精品酒店", "更多酒店住宿" },
    { "全部爱车", "维修保养", "驾校", "停车场", "4S店/汽车销售", "加油站", "配件/车饰", "汽车租赁",
    "汽车保险" },
    { "全部亲子", "亲子摄影", "幼儿教育", "亲子游乐", "孕产护理", "亲子购物", "更多亲子服务" },
    { "全部生活服务", "医院", "银行", "齿科", "宠物", "培训", "快照/冲印", "学校", "旅行社",
    "购物网站", "干洗店", "家政", "奢侈品护理", "商务楼", "小区", "更多生活服务" },
    { "全部家装", "家具家装", "家用电器", "建材", "家装卖场", "装修设计" } };
    // shoplist中排序文本
    // public static String[] SHOPLIST_THREELIST = { "默认排序", "距离最近", "人气最高",
    // "评价最好", "口味最佳", "环境最雅", "服务最好", "费用最低", "费用最高" };


    public static String[] SHOPLIST_THREELIST = { "默认排序", "距离最近", "人气最高",
    "评价最好", "服务最好" };


    // shoplist中商区文本
    public static String[] SHOPLIST_PLACE = new String[] { "附近", "全城热门商区",
    "道里区", "道外区", "南岗区", "香坊区", "平房区", "松北区", "呼兰区", "近郊" };
    // 美食全部地区数组2
    public static String[][] SHOPLIST_PLACESTREET = new String[][] {
    { "500米", "1000米", "2000米", "5000米" },
    { "全部商区", "中央大街", "开发区", "秋林", "哈工大", "菜艺街", "爱建社区", "芦家街/宣化街",
    "新阳路", "学府路", "三大动力路", "革新街", "江畔景区", "南极区", "和兴路沿线",
    "哈尔滨东站", "群力地区", "军工院", "阿城区", },
    { "全部道里区", "中央大街", "爱建社区", "新阳路", "群力地区", "顾乡" },
    { "全部道外区", "江畔景区", "南极街", "哈尔滨东站", "太平桥", "靖宇街沿线", "宏伟路" },
    { "全部南岗区", "开发区", "秋林", "哈工大", "芦家街/宣化街", "学府路", "革新街", "和兴路沿线",
    "军工院", "哈尔滨站", "哈西大街", },
    { "全部香坊区", "菜艺街", "三大动力路", "民生路", "木材街", "安埠街", },
    { "全部平房区", "新疆大街", },
    { "全部松北区", "太阳岛", "世茂大道", "中源大道", },
    { "全部呼兰区", "学院路", },
    { "全部近郊", "阿城区", "尚志市", "五常市", "宾县", "方正县", "延寿县", "双城市", "通河县",
    "巴彦县", "木兰县", "依兰县", } };


    }


    public class SearchMainAdapter extends BaseAdapter {


    private Context ctx;
    private List<Map<String, Object>> list;
    private int position = 0;
    private boolean islodingimg = true;
    private int layout = R.layout.search_more_mainlist_item;


    public SearchMainAdapter(Context ctx, List<Map<String, Object>> list) {
    this.ctx = ctx;
    this.list = list;
    }


    public SearchMainAdapter(Context ctx, List<Map<String, Object>> list,
    int layout, boolean islodingimg) {
    this.ctx = ctx;
    this.list = list;
    this.layout = layout;
    this.islodingimg = islodingimg;
    }


    public int getCount() {
    return list.size();
    }


    public Object getItem(int arg0) {
    return list.get(arg0);
    }


    public long getItemId(int arg0) {
    return arg0;
    }


    public View getView(int arg0, View arg1, ViewGroup arg2) {
    Holder hold;
    if (arg1 == null) {
    hold = new Holder();
    arg1 = View.inflate(ctx, layout, null);
    hold.txt = (TextView) arg1
    .findViewById(R.id.Search_more_mainitem_txt);
    hold.img = (ImageView) arg1
    .findViewById(R.id.Search_more_mainitem_img);
    hold.layout = (LinearLayout) arg1
    .findViewById(R.id.Search_more_mainitem_layout);
    arg1.setTag(hold);
    } else {
    hold = (Holder) arg1.getTag();
    }
    if(islodingimg == true){
    hold.img.setImageResource(Integer.parseInt(list.get(arg0).get("img")
    .toString()));
    }
    hold.txt.setText(list.get(arg0).get("txt").toString());
    hold.layout
    .setBackgroundResource(R.drawable.search_more_mainlistselect);
    if (arg0 == position) {
    hold.layout.setBackgroundResource(R.drawable.list_bkg_line_u);
    }
    return arg1;
    }


    public void setSelectItem(int i) {
    position = i;
    }


    public int getSelectItem() {
    return position;
    }


    private static class Holder {
    LinearLayout layout;
    ImageView img;
    TextView txt;
    }


    }


    public class SearchMoreAdapter extends BaseAdapter {
    private Context ctx;
    private String[] text;
    private int position = 0;
    private int layout = R.layout.search_more_morelist_item;


    public SearchMoreAdapter(Context ctx, String[] text) {
    this.ctx = ctx;
    this.text = text;
    }


    public SearchMoreAdapter(Context ctx, String[] text, int layout) {
    this.ctx = ctx;
    this.text = text;
    this.layout = layout;
    }


    public int getCount() {
    return text.length;
    }


    public Object getItem(int arg0) {
    return text[arg0];
    }


    public long getItemId(int arg0) {
    return arg0;
    }


    public View getView(int arg0, View arg1, ViewGroup arg2) {
    Holder hold;
    if (arg1 == null) {
    hold = new Holder();
    arg1 = View.inflate(ctx, layout, null);
    hold.txt = (TextView) arg1
    .findViewById(R.id.Search_more_moreitem_txt);
    hold.layout = (LinearLayout) arg1
    .findViewById(R.id.More_list_lishi);
    arg1.setTag(hold);
    } else {
    hold = (Holder) arg1.getTag();
    }
    hold.txt.setText(text[arg0]);
    hold.layout.setBackgroundResource(R.drawable.my_list_txt_background);
    hold.txt.setTextColor(Color.parseColor("#FF666666"));
    if (arg0 == position) {
    hold.layout
    .setBackgroundResource(R.drawable.search_more_morelisttop_bkg);
    hold.txt.setTextColor(Color.parseColor("#FFFF8C00"));
    }
    return arg1;
    }


    public void setSelectItem(int i) {
    position = i;
    }


    private static class Holder {
    LinearLayout layout;
    TextView txt;
    }
    }



    布局文件shop_list1_item:

    <?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:orientation="horizontal"
        android:padding="0dp" >


        <LinearLayout
            android:id="@+id/Search_more_mainitem_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/search_more_mainlistselect"
            android:gravity="center_vertical"
            android:orientation="horizontal"
            android:padding="0dp" >


            <ImageView
                android:id="@+id/Search_more_mainitem_img"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="11dp"
                android:paddingLeft="10dp"
                android:paddingTop="11dp" />


            <!-- android:src="@drawable/ic_category_2147483648" -->
            
            <TextView
                android:id="@+id/Search_more_mainitem_txt"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingLeft="10dp"
                android:paddingBottom="9dp"
                android:paddingTop="9dp"
                android:text="热门分类"
                android:textColor="#000000"
                android:textSize="18sp" />
        </LinearLayout>


    </LinearLayout>


    布局文件shop_list2_item:

    <?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="@drawable/my_tab_background"
        android:orientation="vertical"
        android:paddingBottom="0dp"
        android:paddingLeft="10dp" >


        <LinearLayout
            android:id="@+id/More_list_lishi"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/my_list_txt_background"
            android:gravity="center_vertical"
            android:paddingBottom="0dp" >


            <TextView
                android:id="@+id/Search_more_moreitem_txt"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:paddingBottom="8.5dp"
                android:paddingTop="8dp"
                android:text="全部分类"
                android:textColor="#666666"
                android:textSize="17sp" />
        </LinearLayout>


    </LinearLayout>

    展开全文
  • 超简单的多级下拉菜单,一个公式搞定,不需要定义名称!
  • 这是我做项目的时候接触到的一个需求,然后实现了。它仿大众点评,美团等的多级下拉列表菜单。代码干净,可复用性好,希望对大家有所帮助。
  • 用CSS列表<ul><li>,js事件等实现多级下拉列表
  • 主要介绍了Android仿美团淘宝实现多级下拉列表菜单功能,非常不错,具有参考借鉴价值,需要的朋友参考下
  • json数据创建多级下拉菜单是一款基于jQuery使用json数据格式动态创建多级下拉收缩菜单导航代码。
  • android仿美团多级下拉列表菜单实现

    热门讨论 2015-10-31 09:50:01
    android仿美团多级下拉列表菜单实现,满足大多数用户的需求。
  • jquery-accordion-menu-multilevel是一款非常酷的Material Design风格多级下拉列表菜单jQuery插件。该下拉列表在菜单项点击时采用漂亮的点击波特效,并提供了三种预设的颜色主题样式。
  • js javascript 多级下拉列表联动 正则表达式
  • ajax实现多级下拉列表选择

    ajax实现多级下拉列表选择

    ajax.js

    function ajax (options){
        var defaults = {
            type: "get",
            url: "",
            async: true,
            data: {},
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            success: function () {},
            error: function () {},
        }
        Object.assign(defaults, options);
        var xhr = new XMLHttpRequest();
        xhr.open(defaults.type, defaults.url);
        if (defaults.type == 'get') {
            for (i in defaults.data){
                params = i + i.value + "&"
            }
            params = params.substring(0, params.length - 1)
            defaults.url = defaults.url + '?' + params;
        }
        if (defaults.type == 'post') {
            var contentType = defaults.header['Content-Type']
            xhr.setRequestHeader('Content-Type', contentType);
            if (contentType == 'application.json') {
                xhr.send(JSON.stringify(defaults.data));
            }
            else{
                xhr.send(defaults.data);
            }
        }
        else {
            xhr.send();
        }
        xhr.onload = function () {
            var contentType = xhr.getResponseHeader('Content-Type');
            var responseText = xhr.responseText;
            if (contentType.includes('application/json')) {
                responseText = JSON.parse(responseText);
            }
            if (xhr.status == 200){
                defaults.success(responseText, xhr);
            }
            else{
                defaults.error(responseText, xhr);
            }
        }
    }
    
    

    index.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>index</title>
    </head>
    <body>
    <form method="POST" action="/getInfo" target="_blank">
        <fieldset>
            <legend>Information:</legend>
            From&nbsp;<input type="date" name="k1" min="2019-12-24" required="required">
            &nbsp;To&nbsp;<input type="date" name="k2" required="required">&nbsp;&nbsp;
            <i id="ymd"></i><br><br>
        <script>
            var date = new Date()           <!--获得日期数据-->
            var y = date.getFullYear();     <!---->
            var m = date.getMonth()+1;      <!--月,这里的月份必须要+1才是当前月份-->
            var d = date.getDate();         <!--日,getDay是获得当前星期几(0-6),getDate是获得当前日期-->
            var today = y+"-"+m+"-"+d
            document.getElementById("ymd").innerHTML = "当前日期:"+y+"-"+m+"-"+d + " (不要超过这个日期)";
        </script>
        <select name="selectProduct" id="idProduct">
            <option>Select Product</option>
            {% for i in names %}
            <option value="{{ i[0] }}">{{ i[0] }}</option>
            {% endfor %}
        </select>
        <select name="selectCluster" id="idCluster">
            <option>Select Cluster</option>
            {% for i in data %}
            <option value="{{i}}">{{i}}</option>
            {% endfor %}
        </select>
        <select name="selectService" id="idService">
            <option>Select Service</option>
            {% for i in data%}
            <option value="{{i}}">{{i}}</option>
            {% endfor %}
        </select>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="Reset">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="Submit">
        </fieldset>
    </form>
    <div id="plt" align="center">
        <h5>数据查询日期范围:{{ now_date }}</h5>
        <img src="{{ imds }}">
    </div>
    <script src="{{ url_for('static', filename='js/ajax.js') }}"></script>
    <script src="{{ url_for('static', filename='js/template-web.js') }}"></script>
    <script>
        var product = document.getElementById('idProduct');
        var cluster = document.getElementById('idCluster');
        var service = document.getElementById('idService');
        product.onchange = function () {
        var name = this.value;
            ajax({
                type: 'post',
                data: {name: name},
                header: {'Content-Type': 'application.json'},
                url : 'http://127.0.0.1/getCluster',
                success: function (data) {
                    console.log(data);
                    cluster.innerHTML = "<option>Select Cluster</option>";
                    if (data) {
                        for (i=0;i<data.length;i++){
                            cluster.innerHTML += ("<option value='"+data[i]+"'>" + data[i] + "</option>")                 }
                }
            }
        })
    }
        cluster.onchange = function () {
        var name = this.value;
            ajax({
                type: 'post',
                data: {name: name},
                header: {'Content-Type': 'application.json'},
                url : 'http://127.0.0.1/getService',
                success: function (data) {
                    console.log(data);
                    service.innerHTML = "<option>Select Service</option>";
                    if (data) {
                        for (i=0;i<data.length;i++){
                            service.innerHTML += ("<option value='"+data[i]+"'>" + data[i] + "</option>")                 }
                }
            }
        })
    }
    </script>
    </body>
    </html>
    
    

    app.py

    # -*- coding: utf-8 -*-
    from flask import Flask, render_template, request, jsonify
    from useMatplotlib.UseMatplotlib import *
    import time
    
    app = Flask(__name__)
    now_date = time.strftime('%Y-%m-%d')
    
    
    @app.route("/")
    def index():
        sql = '''select distinct product from product where get_time like "{}%"order by product;'''.format(now_date)
        names = ConnMysql().select(sql)
        imd = productMatplotlib(now_date)
        return render_template("index.html", names=names, imds=imd, title="Index", now_date=now_date)
    
    
    @app.route("/getInfo", methods=['GET', 'POST'])
    def get_info():
        i = request.form.to_dict()
        # print(i)
        # ImmutableMultiDict([('k1', '2019-12-24'), ('k2', '2019-12-18'), ...)])
        start_date = i["k1"]
        end_date = i["k2"]
        product = i.get("selectProduct")
        cluster = i.get("selectCluster")
        service = i.get("selectService")
        print(service)
        # print(start_date, end_date, product, cluster, service)
        if service == None:
            # sql = '''select distinct cluster from cluster where product="{}" and get_time >= '{}' AND get_time < '{}'  order by cluster desc;'''.format(product, start_date, end_date)
            # names = ConnMysql().select(sql)
            imd = serviceInfoMatplotlib(product, cluster, start_date, end_date)
            return render_template("info.html", imds=imd, product=product, cluster=cluster, start_date=start_date, end_date=end_date)
        else:
            # sql = '''select distinct cluster from cluster where product="{}" and get_time >= '{}' AND get_time < '{}'  order by cluster desc;'''.format(product, start_date, end_date)
            # names = ConnMysql().select(sql)
            imd = serviceRoleInfoMatplotlib(product, cluster, service, start_date, end_date)
            return render_template("info.html", imds=imd, product=product, cluster=cluster, service=service, start_date=start_date, end_date=end_date)
    
    
    @app.route('/getCluster', methods=['GET', 'POST'])
    def get_cluster():
        i = request.get_data(as_text=True)
        product = eval(i)
        product = product.get('name')
        sql = '''select distinct cluster from cluster where product="{}" and get_time like "{}%" order by cluster;'''.format(product, now_date)
        clusters = ConnMysql().select(sql)
        t = jsonify(clusters)
        return t
    
    
    @app.route('/getService', methods=['GET', 'POST'])
    def get_service():
        i = request.get_data(as_text=True)
        cluster = eval(i)
        cluster = cluster.get('name')
        sql = '''select distinct service from service where cluster="{}" and get_time like "{}%" order by service;'''.format(cluster, now_date)
        services = ConnMysql().select(sql)
        t = jsonify(services)
        return t
    
    
    if __name__ == "__main__":
        app.debug = True
        app.run(port=80)
    
    
    
    展开全文
  • Android开发之多级下拉列表菜单实现(仿美团,淘宝等ExpandTabView 下单时候选择数量时候有美美的动画哦
  • wps 中 下拉列表和多级下拉列表的使用 ** 一,应用目的 期望: 第一列下拉列表选择完 人员类型之后 ,可以在 后面的列中自动 填充 人员对应的 薪资、 人员ID 、 备注信息等。 这样在制作表格时,尤其是在制作 报价...

    **

    wps 中 下拉列表和多级下拉列表的使用

    **

    一,应用目的

    在这里插入图片描述
    期望: 第一列下拉列表选择完 人员类型之后 ,可以在 后面的列中自动 填充 人员对应的 薪资、 人员ID 、 备注信息等。 这样在制作表格时,尤其是在制作 报价清单的时候,可以 极大的缩短工作效率。
    相当于 我们先把 一些重复使用的硬件列一个表格。 后面在制作硬件清单列表的时候, 通过选择硬件名称,后面就可以针对这个硬件,自动出现 单价 和 性能参数 等信息。

    这里面用到的关键技术就是下拉列表。

    二, 实现的步骤

    1, 在WPS excel 中 创建两个表单;
    在这里插入图片描述
    比如: sheet1 文件 是我们需要制作的实际的硬件清单。
    模板: 代表的是 我们自己已经提前制作好的 重复使用次数多的 硬件性能列表。

    2, 模板文件的创建

    在这里插入图片描述

    以上是我们 举例做的一个 模板文件。

    3, 在sheet 中 创建自己的 下拉别表 和 联动(自动填充的列表)

    在这里插入图片描述
    以上是一个 例子。

    (1)测试1 代表的列 ——我们期望使用的是 人员的下拉别表。 选中该列之后,
    在这里插入图片描述
    步骤: 数据—— 插入下拉列表—— 从单元格选择(也可以手动输入,后续再讲)

    选中从 单元格选择之后, 讲鼠标 点击WPS 列表 模板(这是自己起的名字,不是系统自带的模板),跳转到模板的页面

    整个选择 C 列(就是我们想用人员类型下拉列表对应的列)

    在这里插入图片描述

    在这里插入图片描述
    然后 在 sheet 中 的 选择框就会自动出现上面箭头所示的 。

    (2) 联动下拉菜单(关键的一步)

    1. 先在测试1 下面的第一个 空格里面 从下拉列表中 随便 选择一个选项,比如 项目总监。 然后 在 测试2 下面 的第一个表格 里面 插入 公式 VLookup
      在这里插入图片描述
      在这里插入图片描述

    函数参数详细讲解:

    (1)查找值: 可以直接用鼠标点击 测试1 下面的第一个格子 —— 这里对应的是 M3 ,
    注意: 需要我们自己 在前面 加一个 符号 $ ,(别问我原因,我也不知道)
    (2)数据表: 用鼠标定位到 模板的列表, 然后 全部 选中 我们需要的 四列(对应的是 从C 到 F ), 同样的 在选择的第一列 C 的前面 加上一个字符 $
    (3 列序数: 代表的 是我们想在当前这个 格子 里面 填充 查询表里面的第几列(从1开始数。)
    如下 我们 如果选择的是 4 , 就是 填充 对应 模板 数据列表 中的 第四列。
    (4) 匹配条件: 默认填写0 即可。 0 (false)代表的是精确查找。 true(>0)代表的是 模糊查找。

    在这里插入图片描述

    通过以上一系列操作, 基本上就可以实现 联动的效果。

    想象一个场景:

    你要做一个很大的 硬件清单列表, 突然 一个硬件的参数 或者报价 出现变化。 以往,我们就需要将所有相关的 这个硬件 找出来 ,然后 每个都修改一下 响应的参数。

    采用以上方法之后, 只需要在模板里面修改一次, 自己制作的硬件清单会自动全部修改——简直了。

    谨以此文章,献给 做报价清单的程序人员。 在程序员的眼里, 能省事的尽量省事去做,

    展开全文
  • 多级下拉列表(angular)

    千次阅读 2015-10-10 16:49:07
    多级下拉列表 {{label}} var app = angular.module('NameApp', ['ngAnimate']); app.controller("MainCtrl", function($scope){  $scope.people =
    <img src="https://img-blog.csdn.net/20151010170527121?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
    
    <div ng-controller="MainCtrl">
        <select ng-model="selectedPerson" ng-options="obj.name for obj in people"></select>
        <select ng-model="selectedGenre">
            <option ng-repeat="label in people[selectedPerson.id].interest">{{label}}</option>
        </select>
    </div>






    var app = angular.module('NameApp', ['ngAnimate']);
    app.controller("MainCtrl",function($scope){
        $scope.people = [
                        {
                            id: 0,
                            name:'乔乐',
                            interest: [
                                '爬山',
                                '游泳',
                                '旅游',
                                '美食'
                            ]
                        },
                        {
                            id: 1,
                            name:'Chris',
                            interest: [
                                '音乐',
                                '美食',
                                'Coffee',
                                '看书'
                            ]
                        },
                        {
                            id: 2,
                            name:'魏瑞',
                            interest: [
                                '音乐',
                                '电影',
                                '中国好声音',
                                '爸爸去哪了',
                                '非常静距离'
                            ]
                        },
                        {
                            id: 3,
                            name:'小飞子',
                            interest: [
                                '游泳',
                                '游戏',
                                '宅家里'
                            ]
                        }
                    ];
    });
    展开全文
  • Excel 多级联动下拉列表实例
  • 支持多级下拉菜单列表
  • THINKPHP + JQUERY 多级下拉列表联动

    千次阅读 2016-12-01 20:01:54
    THINKPHP + JQUERY 多级下拉列表联动 前几天学习到JQUERY AJAX那一节,有个LOAD 事件。学习完后就想能不能利用LOAD这个事件来写一个多级菜单的联动呢?经过1个多小时的时间,终于写出来了。哈哈,不知道这样写合不...
  • 可以放到项目中用 mutiselect 下拉多选插件 可以放到项目中用 多选下拉列表 复选下拉列表 jquery多选列表 多选多级联动下拉列表,有demo
  • VB 之 精 彩 编 程-VB中多级下拉列表的实现
  • ajax实现多级下拉列表 选省后出现相应的市,ajax 多级select 选省后出现相应的市
  • Android多级下拉列表 菜单 ,可向下选择3级子菜单.zip,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
  • excle多级联动下拉列表模版(省市县) 采用省市县行数据格式,无需处理数据格式,更加方便快捷 内附excle多级联动下拉列表模版供参考
  • 主要为大家介绍了jQuery实现多级联动下拉列表查询框,感兴趣的小伙伴们可以参考一下
  • //触发下拉事件 $('#province').trigger('change'); } },"json"); //省改变加载市 $("#province").change(function(){ //省改变其它默认初始化 $("#lawyerStation").html("请选择律师事务所</option>...
  • 老师,请问这个多级下拉列表怎么做?要明白这个效果怎么做,你必须清楚下面这几点,这是 Excel 必备的基础。第一,如何制作下拉列表?下拉列表的本质是什么?第二,如何给每个单元格制作对应的下拉选项?注意看,当...
  • android--多级下拉列表菜单的实现

    千次阅读 2014-09-28 09:01:35
    原文链接:http://blog.csdn.net/minimicall/article/details/39484493

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 5,130
精华内容 2,052
关键字:

如何创建多级下拉列表