├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── markdown-navigator │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── art ├── ClassifyMenu.gif └── SwipeMenu.gif ├── build.gradle ├── demo ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── net │ │ └── anumbrella │ │ └── menusummary │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── net │ │ │ └── anumbrella │ │ │ └── menusummary │ │ │ ├── Application.java │ │ │ ├── activity │ │ │ ├── ClassifyMenuActivity.java │ │ │ ├── ExpandableGridViewActivity.java │ │ │ ├── ExpandableListViewActivity.java │ │ │ ├── ListGridViewActivity.java │ │ │ ├── ListListViewActivity.java │ │ │ ├── MainActivity.java │ │ │ └── SwipeMenuActivity.java │ │ │ ├── adapter │ │ │ ├── ClassifyMainAdapter.java │ │ │ ├── ClassifyMoreAdapter.java │ │ │ ├── DetailAdapter.java │ │ │ ├── ExpandableGridAdapter.java │ │ │ ├── ExpandableGridTextAdapter.java │ │ │ ├── ExpandableListAdapter.java │ │ │ └── GridViewAdapter.java │ │ │ ├── bean │ │ │ └── Type.java │ │ │ ├── config │ │ │ └── Config.java │ │ │ ├── fragment │ │ │ └── TypeFragment.java │ │ │ ├── utils │ │ │ ├── AppUtils.java │ │ │ └── ToastUtils.java │ │ │ └── widget │ │ │ └── MyGridView.java │ └── res │ │ ├── drawable │ │ ├── text_item_bg.xml │ │ └── text_item_top_bg.xml │ │ ├── layout │ │ ├── activity_classifymenu_layout.xml │ │ ├── activity_expandgridview_layout.xml │ │ ├── activity_expandlistview_layout.xml │ │ ├── activity_listgridview_layout.xml │ │ ├── activity_listlistview_layout.xml │ │ ├── activity_main.xml │ │ ├── activity_swipemenu_layout.xml │ │ ├── detaillist_layout.xml │ │ ├── item_classify_mainlist.xml │ │ ├── item_classify_morelist.xml │ │ ├── item_expandablegrid_child_layout.xml │ │ ├── item_expandablegrid_layout.xml │ │ ├── item_expandablelist_child_layout.xml │ │ ├── item_expandablelist_layout.xml │ │ ├── item_giridview_text.xml │ │ ├── item_gridview.xml │ │ ├── item_swipemenu_list.xml │ │ └── list_item_layout.xml │ │ ├── mipmap-hdpi │ │ ├── group_down.png │ │ ├── group_up.png │ │ ├── ic_category_15.png │ │ ├── ic_category_20.png │ │ ├── ic_category_25.png │ │ ├── ic_category_30.png │ │ ├── ic_category_35.png │ │ ├── ic_category_40.png │ │ ├── ic_category_45.png │ │ ├── ic_category_50.png │ │ ├── ic_category_55.png │ │ ├── ic_category_60.png │ │ ├── ic_launcher.png │ │ └── icon_back.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ ├── dianqi.png │ │ ├── haixian.png │ │ ├── ic_delete.png │ │ ├── ic_launcher.png │ │ ├── jiaju.png │ │ ├── liangbantuan.png │ │ ├── lvxing.png │ │ ├── meishi.png │ │ ├── muying.png │ │ ├── nanzhuang.png │ │ ├── nvzhuang.png │ │ ├── shechipin.png │ │ ├── shipin.png │ │ ├── tazaimai.png │ │ ├── tejia.png │ │ ├── tongzhuang.png │ │ └── zhongbiao.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── net │ └── anumbrella │ └── menusummary │ └── ExampleUnitTest.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── swipemenulibrary ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src ├── androidTest └── java │ └── net │ └── anumbrella │ └── swipemenulibrary │ └── ExampleInstrumentedTest.java ├── main ├── AndroidManifest.xml ├── java │ └── net │ │ └── anumbrella │ │ └── swipemenulibrary │ │ ├── SwipeMenu.java │ │ ├── SwipeMenuAdapter.java │ │ ├── SwipeMenuCreator.java │ │ ├── SwipeMenuItem.java │ │ ├── SwipeMenuLayout.java │ │ ├── SwipeMenuListView.java │ │ └── SwipeMenuView.java └── res │ └── values │ └── strings.xml └── test └── java └── net └── anumbrella └── swipemenulibrary └── ExampleUnitTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/markdown-navigator/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | Java 39 | 40 | 41 | Java language level migration aidsJava 42 | 43 | 44 | 45 | 46 | General 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 68 | 69 | 70 | 71 | 72 | 73 | 78 | 79 | 80 | 81 | 82 | 83 | 1.8 84 | 85 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android常用菜单总结 2 | 3 | [![Platform](https://img.shields.io/badge/platform-android-green.svg)](http://developer.android.com/index.html) 4 | 5 | 对Android开发当中经常用到的一些菜单进行了总结,并对一些好的github控件介绍和简单使用。具体用法看demo。 6 | 7 | 8 | 9 | ### 1. 分类菜单 10 | ![image](https://github.com/Shuyun123/MenuSummary/raw/master/art/ClassifyMenu.gif) 11 | 12 | ### 2.仿QQ滑动删除菜单 13 | ![image](https://github.com/Shuyun123/MenuSummary/raw/master/art/SwipeMenu.gif) 14 | 15 | -------------------------------------------------------------------------------- /art/ClassifyMenu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shuyun123/MenuSummary/d9562351e533a3feddd638d0e8a4600b5c37cc7c/art/ClassifyMenu.gif -------------------------------------------------------------------------------- /art/SwipeMenu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shuyun123/MenuSummary/d9562351e533a3feddd638d0e8a4600b5c37cc7c/art/SwipeMenu.gif -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1' 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | jcenter() 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /demo/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'com.jakewharton.butterknife' 3 | 4 | android { 5 | compileSdkVersion 25 6 | buildToolsVersion "25.0.2" 7 | defaultConfig { 8 | applicationId "net.anumbrella.menusummary" 9 | minSdkVersion 14 10 | targetSdkVersion 25 11 | versionCode 1 12 | versionName "1.0" 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | compile fileTree(include: ['*.jar'], dir: 'libs') 25 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 26 | exclude group: 'com.android.support', module: 'support-annotations' 27 | }) 28 | compile 'com.android.support:appcompat-v7:25.2.0' 29 | testCompile 'junit:junit:4.12' 30 | compile 'com.jakewharton:butterknife:8.5.1' 31 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' 32 | compile project(':swipemenulibrary') 33 | } 34 | -------------------------------------------------------------------------------- /demo/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Volumes/Tools/tools/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /demo/src/androidTest/java/net/anumbrella/menusummary/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("net.anumbrella.menusummary", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /demo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/Application.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary; 2 | 3 | import net.anumbrella.menusummary.utils.AppUtils; 4 | 5 | /** 6 | * author:anumbrella 7 | * Date:17/2/23 下午4:53 8 | */ 9 | 10 | public class Application extends android.app.Application { 11 | @Override 12 | public void onCreate() { 13 | super.onCreate(); 14 | AppUtils.init(this); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/activity/ClassifyMenuActivity.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.activity; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.View; 7 | 8 | import net.anumbrella.menusummary.R; 9 | 10 | import butterknife.ButterKnife; 11 | import butterknife.OnClick; 12 | 13 | /** 14 | * author:anumbrella 15 | * Date:17/2/23 下午1:03 16 | */ 17 | 18 | public class ClassifyMenuActivity extends AppCompatActivity { 19 | 20 | 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_classifymenu_layout); 26 | ButterKnife.bind(this); 27 | } 28 | 29 | 30 | @OnClick({R.id.list,R.id.grid,R.id.expandableGridView,R.id.expandableListView}) 31 | public void click(View view) { 32 | switch (view.getId()){ 33 | case R.id.list: 34 | startActivity(ListListViewActivity.class); 35 | break; 36 | case R.id.grid: 37 | startActivity(ListGridViewActivity.class); 38 | break; 39 | case R.id.expandableListView: 40 | startActivity(ExpandableListViewActivity.class); 41 | break; 42 | case R.id.expandableGridView: 43 | startActivity(ExpandableGridViewActivity.class); 44 | break; 45 | 46 | } 47 | } 48 | 49 | 50 | public void startActivity(Class name){ 51 | Intent intent = new Intent(); 52 | intent.setClass(this,name); 53 | startActivity(intent); 54 | } 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/activity/ExpandableGridViewActivity.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.activity; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | import android.widget.ExpandableListView; 7 | import android.widget.ImageView; 8 | import android.widget.LinearLayout; 9 | 10 | import net.anumbrella.menusummary.R; 11 | import net.anumbrella.menusummary.adapter.ExpandableGridAdapter; 12 | import net.anumbrella.menusummary.config.Config; 13 | 14 | import java.util.ArrayList; 15 | import java.util.HashMap; 16 | import java.util.List; 17 | import java.util.Map; 18 | 19 | import butterknife.BindView; 20 | import butterknife.ButterKnife; 21 | 22 | /** 23 | * author:anumbrella 24 | * Date:17/2/23 下午1:20 25 | */ 26 | 27 | public class ExpandableGridViewActivity extends AppCompatActivity { 28 | 29 | /** 30 | * 二级菜单显示的数据 31 | */ 32 | private String[][] textArray; 33 | 34 | /** 35 | * 展开的标志信息 36 | */ 37 | private int sign = -1; 38 | 39 | private List> list; 40 | 41 | private ExpandableGridAdapter adapter; 42 | 43 | 44 | @BindView(R.id.ExpandableGridView_list) 45 | ExpandableListView expandableGridView; 46 | 47 | 48 | @BindView(R.id.expandableGridView_back) 49 | LinearLayout backImage; 50 | 51 | @Override 52 | protected void onCreate(Bundle savedInstanceState) { 53 | super.onCreate(savedInstanceState); 54 | setContentView(R.layout.activity_expandgridview_layout); 55 | ButterKnife.bind(this); 56 | textArray = Config.EXPANDABLE_MOREGRIDVIEW_TXT; 57 | 58 | // 初始化数据 59 | initData(); 60 | 61 | // 给expandableListView设置监听 62 | setListener(); 63 | 64 | } 65 | 66 | private void setListener() { 67 | expandableGridView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { 68 | 69 | @Override 70 | public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { 71 | if (sign == -1) { 72 | // 选择展开的项 73 | expandableGridView.expandGroup(groupPosition); 74 | // 将展开的项置于顶端 75 | expandableGridView.setSelectedGroup(groupPosition); 76 | sign = groupPosition; 77 | 78 | } else if (sign == groupPosition) { 79 | // 如果已近展开,则将其折叠 80 | expandableGridView.collapseGroup(groupPosition); 81 | sign = -1; 82 | } else { 83 | // 点击其他选项之前,先将之前的关闭掉 84 | expandableGridView.collapseGroup(sign); 85 | expandableGridView.expandGroup(groupPosition); 86 | sign = groupPosition; 87 | } 88 | return true; 89 | } 90 | }); 91 | 92 | backImage.setOnClickListener(new View.OnClickListener() { 93 | 94 | @Override 95 | public void onClick(View v) { 96 | finish(); 97 | } 98 | }); 99 | 100 | } 101 | 102 | private void initData() { 103 | list = new ArrayList>(); 104 | for (int i = 0; i < Config.EXPANDABLE_GRIDVIEW_TXT.length; i++) { 105 | Map map = new HashMap(); 106 | map.put("txt", Config.EXPANDABLE_GRIDVIEW_TXT[i]); 107 | list.add(map); 108 | } 109 | adapter = new ExpandableGridAdapter(this, list, textArray); 110 | expandableGridView.setAdapter(adapter); 111 | } 112 | 113 | 114 | } 115 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/activity/ExpandableListViewActivity.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.activity; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | import android.widget.ExpandableListView; 7 | import android.widget.ImageView; 8 | import android.widget.LinearLayout; 9 | 10 | import net.anumbrella.menusummary.R; 11 | import net.anumbrella.menusummary.adapter.ExpandableListAdapter; 12 | import net.anumbrella.menusummary.config.Config; 13 | import net.anumbrella.menusummary.utils.ToastUtils; 14 | 15 | import java.util.ArrayList; 16 | import java.util.HashMap; 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | import butterknife.BindView; 21 | import butterknife.ButterKnife; 22 | 23 | /** 24 | * author:anumbrella 25 | * Date:17/2/23 下午1:20 26 | */ 27 | 28 | public class ExpandableListViewActivity extends AppCompatActivity { 29 | 30 | 31 | /** 32 | * 定义可扩展listView的适配器 33 | */ 34 | private ExpandableListAdapter adapter; 35 | 36 | private List> list; 37 | 38 | private String[][] textArray; 39 | 40 | 41 | @BindView(R.id.ExpandableListView) 42 | ExpandableListView expandableListView; 43 | 44 | 45 | @BindView(R.id.expandlelist_back) 46 | LinearLayout backImage; 47 | 48 | 49 | @Override 50 | protected void onCreate(Bundle savedInstanceState) { 51 | super.onCreate(savedInstanceState); 52 | setContentView(R.layout.activity_expandlistview_layout); 53 | ButterKnife.bind(this); 54 | textArray = Config.EXPANDABLE_MORELISTVIEW_TXT; 55 | 56 | // 初始化数据 57 | initData(); 58 | 59 | // 给expandableListView设置监听 60 | setListener(); 61 | 62 | } 63 | 64 | 65 | private void initData() { 66 | list = new ArrayList>(); 67 | for (int i = 0; i < Config.EXPANDABLE_LISTVIEW_TXT.length; i++) { 68 | Map map = new HashMap(); 69 | map.put("img", Config.EXPANDABLE_LISTVIEW_IMG[i]); 70 | map.put("txt", Config.EXPANDABLE_LISTVIEW_TXT[i]); 71 | list.add(map); 72 | } 73 | adapter = new ExpandableListAdapter(this, list, textArray); 74 | expandableListView.setAdapter(adapter); 75 | 76 | } 77 | 78 | 79 | private void setListener() { 80 | // 给一级菜单的选项设置监听 81 | expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { 82 | 83 | @Override 84 | public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { 85 | return false; 86 | } 87 | }); 88 | 89 | // 给一级菜单下面的二级菜单的选项设置监听接口 90 | expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { 91 | 92 | @Override 93 | public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { 94 | ToastUtils.showToast("你点击的是" + textArray[groupPosition][childPosition]); 95 | 96 | return false; 97 | } 98 | }); 99 | 100 | // 给返回按钮设置点击事件 101 | backImage.setOnClickListener(new View.OnClickListener() { 102 | @Override 103 | public void onClick(View v) { 104 | finish(); 105 | } 106 | }); 107 | 108 | 109 | } 110 | 111 | 112 | } 113 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/activity/ListGridViewActivity.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.activity; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.view.ViewPager; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.widget.LinearLayout; 10 | import android.widget.ScrollView; 11 | import android.widget.TextView; 12 | 13 | import net.anumbrella.menusummary.R; 14 | import net.anumbrella.menusummary.adapter.DetailAdapter; 15 | import net.anumbrella.menusummary.config.Config; 16 | 17 | import butterknife.BindView; 18 | import butterknife.ButterKnife; 19 | 20 | /** 21 | * author:anumbrella 22 | * Date:17/2/23 下午1:21 23 | */ 24 | 25 | public class ListGridViewActivity extends AppCompatActivity { 26 | 27 | 28 | private String[] list; 29 | 30 | private DetailAdapter detailAdapter; 31 | 32 | private View[] views; 33 | 34 | private TextView[] textList; 35 | 36 | private LayoutInflater inflater; 37 | 38 | 39 | @BindView(R.id.list_scrollView) 40 | ScrollView scrollView; 41 | 42 | 43 | @BindView(R.id.detail_layout) 44 | ViewPager viewPager; 45 | 46 | /** 47 | * 默认的ViewPager选中的项 48 | */ 49 | private int currentItem = 0; 50 | 51 | 52 | @Override 53 | protected void onCreate(@Nullable Bundle savedInstanceState) { 54 | super.onCreate(savedInstanceState); 55 | setContentView(R.layout.activity_listgridview_layout); 56 | ButterKnife.bind(this); 57 | inflater = LayoutInflater.from(this); 58 | initList(); 59 | initViewPager(); 60 | } 61 | 62 | 63 | private void initList() { 64 | list = Config.list; 65 | views = new View[list.length]; 66 | textList = new TextView[list.length]; 67 | LinearLayout listLayout = (LinearLayout) findViewById(R.id.list); 68 | 69 | for (int i = 0; i < list.length; i++) { 70 | View view = inflater.inflate(R.layout.list_item_layout, null); 71 | // 给每个View设定唯一标识 72 | view.setId(i); 73 | // 给每个view添加点击监控事件 74 | view.setOnClickListener(listItemClickListener); 75 | // 获取到左侧栏的的TextView的组件 76 | TextView textView = (TextView) view.findViewById(R.id.textView); 77 | textView.setText(list[i]); 78 | listLayout.addView(view); 79 | // 传入的是地址不是复制的值 80 | textList[i] = textView; 81 | views[i] = view; 82 | } 83 | // 开始默认是第一个被选中的情况 84 | changeTextColor(0); 85 | } 86 | 87 | private void initViewPager() { 88 | 89 | // 由于使用了支持包所以最终必须确保所有的导入包都是来自支持包 90 | detailAdapter = new DetailAdapter(getSupportFragmentManager(), list); 91 | viewPager.setAdapter(detailAdapter); 92 | // 为ViewPager设置页面变化的监控 93 | viewPager.setOnPageChangeListener(onPageChangeListener); 94 | } 95 | 96 | /** 97 | * ViewPager监控事件处理 监听ViewPager选项卡变化事的事件 98 | */ 99 | private ViewPager.OnPageChangeListener onPageChangeListener = new ViewPager.OnPageChangeListener() { 100 | 101 | @Override 102 | public void onPageSelected(int index) { 103 | if (viewPager.getCurrentItem() != index) { 104 | viewPager.setCurrentItem(index); 105 | } 106 | // 通过ViewPager监听点击字体颜色和背景的改变 107 | if (currentItem != index) { 108 | changeTextColor(index); 109 | changeTextLocation(index); 110 | } 111 | currentItem = index; 112 | 113 | } 114 | 115 | @Override 116 | public void onPageScrolled(int arg0, float arg1, int arg2) { 117 | } 118 | 119 | @Override 120 | public void onPageScrollStateChanged(int arg0) { 121 | } 122 | }; 123 | 124 | 125 | /** 126 | * 模拟点击时TextView文本字体颜色的改变情况 127 | * 128 | * @param id 129 | */ 130 | private void changeTextColor(int id) { 131 | for (int i = 0; i < list.length; i++) { 132 | if (id != i) { 133 | textList[i].setBackgroundColor(0x00000000); 134 | textList[i].setTextColor(0xFF000000); 135 | } 136 | } 137 | textList[id].setBackgroundColor(0xFFFFFFFF); 138 | textList[id].setTextColor(0xFFFF5D5E); 139 | 140 | } 141 | 142 | 143 | /** 144 | * view的点击事件, 145 | *

146 | * 通过点击view来是ViewPager的状态发生改变,同时ViewPager监控自己的改变 可以用来处理一些事件的情况 147 | */ 148 | private View.OnClickListener listItemClickListener = new View.OnClickListener() { 149 | 150 | @Override 151 | public void onClick(View v) { 152 | viewPager.setCurrentItem(v.getId()); 153 | } 154 | }; 155 | 156 | 157 | /** 158 | * 改变左侧栏选中项的位置 159 | * 160 | * @param clickPosition 161 | */ 162 | private void changeTextLocation(int clickPosition) { 163 | // 获得点击的view视图距离屏幕顶部的距离 164 | int y = (views[clickPosition].getTop()); 165 | // 如果滑动条可以滑动的情况下就把点击的视图移动到顶部 166 | scrollView.smoothScrollTo(0, y); 167 | 168 | } 169 | 170 | 171 | } 172 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/activity/ListListViewActivity.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.activity; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.View; 7 | import android.widget.AdapterView; 8 | import android.widget.ListView; 9 | 10 | import net.anumbrella.menusummary.R; 11 | import net.anumbrella.menusummary.adapter.ClassifyMainAdapter; 12 | import net.anumbrella.menusummary.adapter.ClassifyMoreAdapter; 13 | import net.anumbrella.menusummary.config.Config; 14 | import net.anumbrella.menusummary.utils.ToastUtils; 15 | 16 | import java.util.ArrayList; 17 | import java.util.HashMap; 18 | import java.util.List; 19 | import java.util.Map; 20 | 21 | import butterknife.BindView; 22 | import butterknife.ButterKnife; 23 | 24 | /** 25 | * author:anumbrella 26 | * Date:17/2/23 下午1:20 27 | */ 28 | 29 | public class ListListViewActivity extends AppCompatActivity { 30 | 31 | private ClassifyMainAdapter classifyMainAdapter; 32 | 33 | private ClassifyMoreAdapter classifyMoreAdapter; 34 | 35 | private List> mainList; 36 | 37 | 38 | @BindView(R.id.main_view) 39 | ListView mainlist; 40 | 41 | @BindView(R.id.more_view) 42 | ListView morelist; 43 | 44 | 45 | private int mainSelectPostion = 0; 46 | 47 | 48 | @Override 49 | protected void onCreate(@Nullable Bundle savedInstanceState) { 50 | super.onCreate(savedInstanceState); 51 | setContentView(R.layout.activity_listlistview_layout); 52 | ButterKnife.bind(this); 53 | initModelData(); 54 | initView(); 55 | } 56 | 57 | private void initView() { 58 | classifyMainAdapter = new ClassifyMainAdapter(this, mainList); 59 | // 默认选中第一个选项 60 | mainlist.setSelection(0); 61 | // 建立数据适配 62 | mainlist.setAdapter(classifyMainAdapter); 63 | 64 | // 设置listView当中的每个单项点击的事件变化逻辑处理 65 | mainlist.setOnItemClickListener(new AdapterView.OnItemClickListener() { 66 | 67 | // 主目录的点击事件发生后,就要为侧目进行数据的交互 68 | @Override 69 | public void onItemClick(AdapterView parent, View view, int position, long id) { 70 | mainSelectPostion = position; 71 | // 主目录一位数组的大小和侧目录二维数组的行的数目是一致的 72 | // 点击传入二维数组的一行的数据 73 | inintAdapter(Config.MORELISTVIEWTXT[position]); 74 | // 设置选中的选的id 75 | classifyMainAdapter.setSelectItem(position); 76 | // 更新数据的变更 77 | classifyMainAdapter.notifyDataSetChanged(); 78 | 79 | } 80 | 81 | }); 82 | 83 | /** 84 | * CHOICE_MODE_NONE是普通模式 85 | * 86 | * CHOICE_MODE_SINGLE是单选模式,不常用 87 | * 88 | * CHOICE_MODE_MULTIPLE和CHOICE_MODE_MULTIPLE_MODAL都是多选模式 89 | * 90 | * 设置选着的模式 91 | * */ 92 | mainlist.setChoiceMode(ListView.CHOICE_MODE_SINGLE); 93 | 94 | // 设置还没有点击时默认的显示页面的内容 95 | inintAdapter(Config.MORELISTVIEWTXT[0]); 96 | 97 | // 设置详细列表的点击事件处理逻辑 98 | morelist.setOnItemClickListener(new AdapterView.OnItemClickListener() { 99 | 100 | @Override 101 | public void onItemClick(AdapterView parent, View view, int position, long id) { 102 | classifyMoreAdapter.setSelectItem(position); 103 | classifyMoreAdapter.notifyDataSetChanged(); 104 | ToastUtils.showToast("你点击的是" + Config.MORELISTVIEWTXT[mainSelectPostion][position]); 105 | 106 | } 107 | }); 108 | 109 | 110 | } 111 | 112 | 113 | /** 114 | * 为侧目录(详细目录)进行数据的匹配处理 115 | * @param array 116 | */ 117 | private void inintAdapter(String[] array) { 118 | classifyMoreAdapter = new ClassifyMoreAdapter(this, array); 119 | morelist.setAdapter(classifyMoreAdapter); 120 | classifyMoreAdapter.notifyDataSetChanged(); 121 | } 122 | 123 | 124 | 125 | /** 126 | * 初始化化数据的设定(String在java中为对象存储的,不是基本的常量) 127 | */ 128 | private void initModelData() { 129 | 130 | mainList = new ArrayList>(); 131 | for (int i = 0; i < Config.LISTVIEWTXT.length; i++) { 132 | Map map = new HashMap(); 133 | // 根据键值对存储到HashMap中去 134 | map.put("img", Config.LISTVIEWIMG[i]); 135 | map.put("txt", Config.LISTVIEWTXT[i]); 136 | mainList.add(map); 137 | } 138 | 139 | } 140 | 141 | 142 | } 143 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/activity/MainActivity.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.activity; 2 | 3 | import android.content.Intent; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | import android.widget.Button; 8 | 9 | import net.anumbrella.menusummary.R; 10 | 11 | import butterknife.BindView; 12 | import butterknife.ButterKnife; 13 | import butterknife.OnClick; 14 | 15 | public class MainActivity extends AppCompatActivity { 16 | 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_main); 22 | ButterKnife.bind(this); 23 | } 24 | 25 | @OnClick({R.id.classifyMenu,R.id.SwipeMenu}) 26 | public void click(View view){ 27 | switch (view.getId()){ 28 | case R.id.classifyMenu: 29 | startActivity(ClassifyMenuActivity.class); 30 | break; 31 | case R.id.SwipeMenu: 32 | startActivity(SwipeMenuActivity.class); 33 | break; 34 | } 35 | } 36 | 37 | 38 | public void startActivity(Class name){ 39 | Intent intent = new Intent(); 40 | intent.setClass(this,name); 41 | startActivity(intent); 42 | } 43 | 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/activity/SwipeMenuActivity.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.activity; 2 | 3 | import android.content.ComponentName; 4 | import android.content.Intent; 5 | import android.content.pm.ApplicationInfo; 6 | import android.content.pm.ResolveInfo; 7 | import android.graphics.Color; 8 | import android.graphics.drawable.ColorDrawable; 9 | import android.os.Bundle; 10 | import android.support.v7.app.AppCompatActivity; 11 | import android.util.TypedValue; 12 | import android.view.View; 13 | import android.view.ViewGroup; 14 | import android.widget.AdapterView; 15 | import android.widget.BaseAdapter; 16 | import android.widget.ImageView; 17 | import android.widget.TextView; 18 | 19 | import net.anumbrella.menusummary.R; 20 | import net.anumbrella.menusummary.utils.ToastUtils; 21 | import net.anumbrella.swipemenulibrary.SwipeMenu; 22 | import net.anumbrella.swipemenulibrary.SwipeMenuCreator; 23 | import net.anumbrella.swipemenulibrary.SwipeMenuItem; 24 | import net.anumbrella.swipemenulibrary.SwipeMenuListView; 25 | 26 | import java.util.List; 27 | 28 | import butterknife.BindView; 29 | import butterknife.ButterKnife; 30 | 31 | /** 32 | * author:anumbrella 33 | * Date:17/2/24 下午1:33 34 | */ 35 | public class SwipeMenuActivity extends AppCompatActivity { 36 | 37 | 38 | /** 39 | * App应用信息 40 | */ 41 | private List mAppList; 42 | 43 | private AppAdapter mAdapter; 44 | 45 | @BindView(R.id.listView) 46 | SwipeMenuListView mListView; 47 | 48 | 49 | @Override 50 | public void onCreate(Bundle savedInstanceState) { 51 | super.onCreate(savedInstanceState); 52 | setContentView(R.layout.activity_swipemenu_layout); 53 | ButterKnife.bind(this); 54 | 55 | // 获取已经安装的软件信息 56 | mAppList = getPackageManager().getInstalledApplications(0); 57 | 58 | mAdapter = new AppAdapter(); 59 | 60 | mListView.setAdapter(mAdapter); 61 | 62 | init(); 63 | 64 | 65 | } 66 | 67 | private void init() { 68 | // 创建操作菜单 69 | SwipeMenuCreator creator = new SwipeMenuCreator() { 70 | 71 | // 定义回调方法(接口SwipeMenuCreator) 72 | @Override 73 | public void create(SwipeMenu menu) { 74 | // 添加打开操作选项 75 | SwipeMenuItem openItem = new SwipeMenuItem( 76 | getApplicationContext()); 77 | 78 | // 设置背景颜色 79 | openItem.setBackground(new ColorDrawable(Color.rgb(0xC9, 0xC9, 80 | 0xCE))); 81 | // 设置宽度 82 | openItem.setWidth(dp2px(90)); 83 | // 设置标题 84 | openItem.setTitle("open"); 85 | // 设置标题字体大小 86 | openItem.setTitleSize(18); 87 | // 设置标题字体颜色 88 | openItem.setTitleColor(Color.WHITE); 89 | // 添加到操作类中 90 | menu.addMenuItem(openItem); 91 | 92 | // 添加删除操作选项 93 | SwipeMenuItem deleteItem = new SwipeMenuItem( 94 | getApplicationContext()); 95 | 96 | // 设置背景颜色 97 | deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9, 98 | 0x3F, 0x25))); 99 | // 设置宽度 100 | deleteItem.setWidth(dp2px(90)); 101 | // 设置操作图标 102 | deleteItem.setIcon(R.mipmap.ic_delete); 103 | // 添加到操作类中 104 | menu.addMenuItem(deleteItem); 105 | 106 | } 107 | }; 108 | 109 | // 设置创建菜单接口引用 110 | mListView.setMenuCreator(creator); 111 | 112 | // 设置点击菜单处理逻辑接口引用 113 | mListView.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() { 114 | // 重写接口方法(回调方法) 115 | @Override 116 | public void onMenuItemClick(int position, SwipeMenu menu, int index) { 117 | ApplicationInfo info = mAppList.get(position); 118 | 119 | switch (index) { 120 | case 0: 121 | // 打开app操作 122 | open(info); 123 | break; 124 | case 1: 125 | // 删除app目录操作 126 | mAppList.remove(position); 127 | mAdapter.notifyDataSetChanged(); 128 | break; 129 | } 130 | } 131 | }); 132 | 133 | mListView.setOnSwipeListener(new SwipeMenuListView.OnSwipeListener() { 134 | 135 | @Override 136 | public void onSwipeStart(int position) { 137 | // 操作菜单滑动前的操作 138 | } 139 | 140 | @Override 141 | public void onSwipeEnd(int position) { 142 | // 操作菜单滑动后的操作 143 | } 144 | }); 145 | // 添加长点击事件 146 | mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { 147 | 148 | @Override 149 | public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { 150 | ToastUtils.showToast(position + "长点击"); 151 | return false; 152 | } 153 | }); 154 | 155 | } 156 | 157 | 158 | /** 159 | * 打开app操作 160 | * 161 | * @param info 162 | */ 163 | private void open(ApplicationInfo info) { 164 | 165 | Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null); 166 | resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER); 167 | resolveIntent.setPackage(info.packageName); 168 | // 配备适合的应用 169 | List resolveInfoList = getPackageManager() 170 | .queryIntentActivities(resolveIntent, 0); 171 | 172 | if (resolveInfoList != null && resolveInfoList.size() > 0) { 173 | // 获得第一应用的启动项 174 | ResolveInfo resolveInfo = resolveInfoList.get(0); 175 | String activityPackageName = resolveInfo.activityInfo.packageName; 176 | String className = resolveInfo.activityInfo.name; 177 | // 组装启动的intent 178 | Intent intent = new Intent(Intent.ACTION_MAIN); 179 | intent.addCategory(Intent.CATEGORY_LAUNCHER); 180 | ComponentName componentName = new ComponentName(activityPackageName, className); 181 | intent.setComponent(componentName); 182 | startActivity(intent); 183 | } 184 | 185 | } 186 | 187 | 188 | /** 189 | * app应用适配器 190 | */ 191 | private class AppAdapter extends BaseAdapter { 192 | 193 | @Override 194 | public int getCount() { 195 | return mAppList.size(); 196 | } 197 | 198 | @Override 199 | public ApplicationInfo getItem(int position) { 200 | return mAppList.get(position); 201 | } 202 | 203 | @Override 204 | public long getItemId(int position) { 205 | return position; 206 | } 207 | 208 | @Override 209 | public View getView(int position, View convertView, ViewGroup parent) { 210 | 211 | if (convertView == null) { 212 | convertView = View.inflate(getApplicationContext(), 213 | R.layout.item_swipemenu_list, null); 214 | new ViewHolder(convertView); 215 | } 216 | ViewHolder viewHolder = (ViewHolder) convertView.getTag(); 217 | ApplicationInfo item = getItem(position); 218 | // 获得应用的图标 219 | viewHolder.iv_icon.setImageDrawable(item 220 | .loadIcon(getPackageManager())); 221 | viewHolder.tv_name.setText(item.loadLabel(getPackageManager())); 222 | return convertView; 223 | } 224 | } 225 | 226 | class ViewHolder { 227 | private ImageView iv_icon; 228 | private TextView tv_name; 229 | 230 | public ViewHolder(View convertView) { 231 | iv_icon = (ImageView) convertView.findViewById(R.id.iv_icon); 232 | tv_name = (TextView) convertView.findViewById(R.id.tv_name); 233 | convertView.setTag(this); 234 | } 235 | } 236 | 237 | /** 238 | * dp转px 239 | * 240 | * @param dp 241 | * @return 242 | */ 243 | private int dp2px(int dp) { 244 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, 245 | getResources().getDisplayMetrics()); 246 | } 247 | 248 | 249 | } 250 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/adapter/ClassifyMainAdapter.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.BaseAdapter; 7 | import android.widget.ImageView; 8 | import android.widget.LinearLayout; 9 | import android.widget.TextView; 10 | 11 | import net.anumbrella.menusummary.R; 12 | 13 | import java.util.List; 14 | import java.util.Map; 15 | 16 | /** 17 | * author:anumbrella 18 | * Date:17/2/23 下午1:24 19 | * 左侧的数据适配器 20 | */ 21 | 22 | public class ClassifyMainAdapter extends BaseAdapter { 23 | 24 | 25 | private Context mContext; 26 | 27 | private List> list; 28 | 29 | private Hoder hoder; 30 | /** 31 | * 是否要加载显示图片 32 | */ 33 | private boolean isLoadingImage = true; 34 | 35 | /** 36 | * 默认第一个图片是选中了的 37 | */ 38 | private int selectPosition = 0; 39 | 40 | 41 | public ClassifyMainAdapter(Context context, List> list) { 42 | this.mContext = context; 43 | this.list = list; 44 | } 45 | 46 | public ClassifyMainAdapter(Context context, List> list, boolean isLoadingImage) { 47 | this.mContext = context; 48 | this.list = list; 49 | this.isLoadingImage = isLoadingImage; 50 | } 51 | 52 | 53 | 54 | 55 | @Override 56 | public int getCount() { 57 | return list.size(); 58 | } 59 | 60 | @Override 61 | public Object getItem(int position) { 62 | return list.get(position); 63 | } 64 | 65 | @Override 66 | public long getItemId(int position) { 67 | return position; 68 | } 69 | 70 | @Override 71 | public View getView(int position, View convertView, ViewGroup viewGroup) { 72 | if (convertView == null) { 73 | convertView = View.inflate(mContext, 74 | R.layout.item_classify_mainlist, null); 75 | hoder = new Hoder(convertView); 76 | // 把数据存储到convertView当中去 77 | convertView.setTag(hoder); 78 | } else { 79 | hoder = (Hoder) convertView.getTag(); 80 | } 81 | 82 | if (isLoadingImage == true) { 83 | hoder.imageView.setImageResource(Integer.parseInt(list 84 | .get(position).get("img").toString())); 85 | 86 | } 87 | 88 | hoder.layout.setBackgroundColor(0xFFEBEBEB); 89 | hoder.textView.setText(list.get(position).get("txt").toString()); 90 | if (position == selectPosition) { 91 | hoder.layout.setBackgroundColor(0xFFFFFFFF); 92 | } 93 | return convertView; 94 | 95 | } 96 | 97 | public void setSelectItem(int position) { 98 | this.selectPosition = position; 99 | } 100 | 101 | public int getSelectItem() { 102 | return this.selectPosition; 103 | } 104 | 105 | 106 | private static class Hoder { 107 | 108 | private ImageView imageView; 109 | private TextView textView; 110 | private LinearLayout layout; 111 | 112 | public Hoder(View view) { 113 | imageView = (ImageView) view.findViewById(R.id.mainItem_img); 114 | textView = (TextView) view.findViewById(R.id.mainItem_txt); 115 | layout = (LinearLayout) view.findViewById(R.id.mainList_layout); 116 | 117 | } 118 | 119 | } 120 | 121 | 122 | } 123 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/adapter/ClassifyMoreAdapter.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.BaseAdapter; 7 | import android.widget.TextView; 8 | 9 | import net.anumbrella.menusummary.R; 10 | 11 | /** 12 | * author:anumbrella 13 | * Date:17/2/23 下午1:33 14 | * 右侧的数据适配器 15 | */ 16 | 17 | public class ClassifyMoreAdapter extends BaseAdapter { 18 | 19 | 20 | private String[] listMore; 21 | 22 | private Context mContext; 23 | /** 24 | * 默认选中第一个 25 | */ 26 | private int selectPosition = 0; 27 | 28 | 29 | private Hoder hoder; 30 | 31 | public ClassifyMoreAdapter(Context context, String[] list) { 32 | this.listMore = list; 33 | this.mContext = context; 34 | } 35 | 36 | 37 | public void setSelectItem(int position) { 38 | this.selectPosition = position; 39 | } 40 | 41 | public int getSelectItem() { 42 | return this.selectPosition; 43 | } 44 | 45 | @Override 46 | public int getCount() { 47 | return listMore.length; 48 | } 49 | 50 | @Override 51 | public Object getItem(int position) { 52 | return listMore[position]; 53 | } 54 | 55 | @Override 56 | public long getItemId(int position) { 57 | return position; 58 | } 59 | 60 | @Override 61 | public View getView(int position, View convertView, ViewGroup viewGroup) { 62 | if (convertView == null) { 63 | convertView = View.inflate(mContext, 64 | R.layout.item_classify_morelist, null); 65 | hoder = new Hoder(convertView); 66 | convertView.setTag(hoder); 67 | } else { 68 | hoder = (Hoder) convertView.getTag(); 69 | } 70 | hoder.textView.setText(listMore[position]); 71 | hoder.textView.setTextColor(0xFF666666); 72 | if (position == selectPosition) { 73 | hoder.textView.setTextColor(0xFFFF8C00); 74 | } 75 | 76 | return convertView; 77 | } 78 | 79 | 80 | private static class Hoder { 81 | private TextView textView; 82 | 83 | public Hoder(View view) { 84 | textView = (TextView) view.findViewById(R.id.moreItem_text); 85 | } 86 | 87 | } 88 | 89 | 90 | } 91 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/adapter/DetailAdapter.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.adapter; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.support.v4.app.FragmentManager; 6 | import android.support.v4.app.FragmentPagerAdapter; 7 | 8 | import net.anumbrella.menusummary.fragment.TypeFragment; 9 | 10 | /** 11 | * author:anumbrella 12 | * Date:17/2/23 下午2:24 13 | * 14 | * fragment的适配器(右侧ViewPager加载选项卡) 15 | * 16 | * Fragment对象会一直存留在内存中,所以当有大量的显示页时,就不适合用FragmentPagerAdapter 17 | * 了,FragmentPagerAdapter 适用于只有少数的page情况,像选项卡。。 18 | * 当比较多fragment时,选择FragmentStatePagerAdapter 19 | */ 20 | 21 | public class DetailAdapter extends FragmentPagerAdapter { 22 | 23 | private String[] list; 24 | 25 | public DetailAdapter(FragmentManager fm,String[] array) { 26 | super(fm); 27 | this.list = array; 28 | } 29 | 30 | @Override 31 | public Fragment getItem(int position) { 32 | Fragment fragment = new TypeFragment(); 33 | Bundle bundle = new Bundle(); 34 | // 把选中的index指针传入过去 35 | bundle.putInt("index", position); 36 | // 设定在fragment当中去 37 | fragment.setArguments(bundle); 38 | return fragment; 39 | } 40 | 41 | @Override 42 | public int getCount() { 43 | return list.length; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/adapter/ExpandableGridAdapter.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.AdapterView; 7 | import android.widget.BaseExpandableListAdapter; 8 | import android.widget.TextView; 9 | 10 | import net.anumbrella.menusummary.R; 11 | import net.anumbrella.menusummary.utils.ToastUtils; 12 | import net.anumbrella.menusummary.widget.MyGridView; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | import java.util.Map; 17 | 18 | /** 19 | * author:anumbrella 20 | * Date:17/2/23 下午3:38 21 | */ 22 | public class ExpandableGridAdapter extends BaseExpandableListAdapter implements AdapterView.OnItemClickListener { 23 | 24 | 25 | /** 26 | * 二级菜单选项的显示内容 27 | */ 28 | private String[][] text_array; 29 | 30 | /** 31 | * 一级菜单选项的显示内容 32 | */ 33 | private List> list; 34 | 35 | /** 36 | * 自定义的视图 37 | */ 38 | private MyGridView myGridView; 39 | 40 | private Context context; 41 | 42 | private List child_text; 43 | 44 | 45 | public ExpandableGridAdapter(Context context, List> list, String[][] array) { 46 | this.context = context; 47 | this.list = list; 48 | this.text_array = array; 49 | } 50 | 51 | 52 | /** 53 | * 获取第一级菜单的选的总数目 54 | * 55 | * @return 56 | */ 57 | @Override 58 | public int getGroupCount() { 59 | return list.size(); 60 | } 61 | 62 | /** 63 | * 获取一级菜单下面二级菜单的选项的总数目 64 | * 65 | * @param i 66 | * @return 67 | */ 68 | @Override 69 | public int getChildrenCount(int i) { 70 | // 这里返回1是为了让ExpandableListView只显示一个ChildView,否则在展开 71 | // ExpandableListView时会显示和ChildCount数量相同的GridView 72 | return 1; 73 | } 74 | 75 | /** 76 | * 获取一级菜单的具体的选项的内容 77 | * 78 | * @param groupPosition 79 | * @return 80 | */ 81 | @Override 82 | public Object getGroup(int groupPosition) { 83 | return list.get(groupPosition).get("txt"); 84 | } 85 | 86 | /** 87 | * 获取一级菜单下第二级菜单的具体的选项的内容 88 | * 89 | * @return 90 | */ 91 | @Override 92 | public Object getChild(int groupPosition, int childPosition) { 93 | return text_array[groupPosition][childPosition]; 94 | } 95 | 96 | /** 97 | * 获取第一级菜单的选项的id 98 | * 99 | * @param i 100 | * @return 101 | */ 102 | @Override 103 | public long getGroupId(int i) { 104 | return i; 105 | } 106 | 107 | /** 108 | * 获取二级菜单的选项的id 109 | * 110 | * @param i 111 | * @param i1 112 | * @return 113 | */ 114 | @Override 115 | public long getChildId(int i, int i1) { 116 | return i1; 117 | } 118 | 119 | /** 120 | * 指定位置相应的组视图(指定视图相应的id) 121 | * 122 | * @return 123 | */ 124 | @Override 125 | public boolean hasStableIds() { 126 | return false; 127 | } 128 | 129 | /** 130 | * 对一级菜单的标签的内容进行设置 131 | * 132 | * @param viewGroup 133 | * @return 134 | */ 135 | @Override 136 | public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup viewGroup) { 137 | convertView = convertView.inflate(context, R.layout.item_expandablegrid_layout, null); 138 | TextView textView = (TextView) convertView.findViewById(R.id.item_expandablegrid_text); 139 | 140 | if (isExpanded) { 141 | textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.mipmap.group_down, 0); 142 | } else { 143 | textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.mipmap.group_up, 0); 144 | } 145 | 146 | textView.setText(list.get(groupPosition).get("txt").toString()); 147 | return convertView; 148 | } 149 | 150 | /** 151 | * 对一级菜单下面的二级菜单进行设置 152 | * 153 | * @param i1 154 | * @param b 155 | * @param viewGroup 156 | * @return 157 | */ 158 | @Override 159 | public View getChildView(int groupPosition, int i1, boolean b, View convertView, ViewGroup viewGroup) { 160 | convertView = convertView.inflate(context, 161 | R.layout.item_expandablegrid_child_layout, null); 162 | myGridView = (MyGridView) convertView.findViewById(R.id.MyGridView); 163 | 164 | int size = text_array[groupPosition].length; 165 | child_text = new ArrayList(); 166 | for (int i = 0; i < size; i++) { 167 | child_text.add(text_array[groupPosition][i]); 168 | } 169 | 170 | myGridView.setAdapter(new ExpandableGridTextAdapter(child_text, context)); 171 | myGridView.setOnItemClickListener(this); 172 | 173 | return convertView; 174 | } 175 | 176 | /** 177 | * 当选择子节点的时候,调用该方法 178 | * 179 | * @param i 180 | * @param i1 181 | * @return 182 | */ 183 | @Override 184 | public boolean isChildSelectable(int i, int i1) { 185 | return true; 186 | 187 | } 188 | 189 | 190 | /** 191 | * 二级菜单选项点击事件 192 | * 193 | * @param adapterView 194 | * @param view 195 | * @param l 196 | */ 197 | @Override 198 | public void onItemClick(AdapterView adapterView, View view, int position, long l) { 199 | ToastUtils.showToast("你点击的是" + child_text.get(position)); 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/adapter/ExpandableGridTextAdapter.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.BaseAdapter; 7 | import android.widget.TextView; 8 | 9 | import net.anumbrella.menusummary.R; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | /** 15 | * author:anumbrella 16 | * Date:17/2/23 下午3:51 17 | */ 18 | 19 | public class ExpandableGridTextAdapter extends BaseAdapter { 20 | 21 | private List child_text_array = new ArrayList(); 22 | 23 | private Context context; 24 | 25 | public ExpandableGridTextAdapter(List list, Context context) { 26 | this.context = context; 27 | this.child_text_array = list; 28 | } 29 | 30 | @Override 31 | public int getCount() { 32 | return child_text_array.size(); 33 | } 34 | 35 | @Override 36 | public Object getItem(int position) { 37 | return child_text_array.get(position); 38 | } 39 | 40 | @Override 41 | public long getItemId(int position) { 42 | return position; 43 | } 44 | 45 | @Override 46 | public View getView(int position, View convertView, ViewGroup parent) { 47 | TextView textView = null; 48 | if (convertView == null) { 49 | convertView = convertView.inflate(context, R.layout.item_giridview_text, null); 50 | textView = (TextView) convertView 51 | .findViewById(R.id.item_expandablegridview_text); 52 | convertView.setTag(textView); 53 | } else { 54 | textView = (TextView) convertView.getTag(); 55 | } 56 | textView.setText(child_text_array.get(position)); 57 | return convertView; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/adapter/ExpandableListAdapter.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.BaseExpandableListAdapter; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import net.anumbrella.menusummary.R; 11 | 12 | import java.util.List; 13 | import java.util.Map; 14 | 15 | /** 16 | * author:anumbrella 17 | * Date:17/2/23 下午3:09 18 | * 扩展视图的适配器 19 | */ 20 | 21 | public class ExpandableListAdapter extends BaseExpandableListAdapter { 22 | 23 | 24 | private String[][] text_array; 25 | 26 | private Context context; 27 | 28 | private List> list; 29 | 30 | public ExpandableListAdapter(Context context, List> list, String[][] array) { 31 | this.context = context; 32 | // 子菜单的选项的数据 33 | this.text_array = array; 34 | // 父菜单的选项的数据 35 | this.list = list; 36 | } 37 | 38 | /** 39 | * 获取第一级菜单的选的总数目 40 | * 41 | * @return 42 | */ 43 | @Override 44 | public int getGroupCount() { 45 | return list.size(); 46 | } 47 | 48 | /** 49 | * 获取一级菜单下面二级菜单的选项的总数目 50 | * 51 | * @param i 52 | * @return 53 | */ 54 | @Override 55 | public int getChildrenCount(int i) { 56 | return text_array[i].length; 57 | 58 | } 59 | 60 | /** 61 | * 获取一级菜单的具体的选项的内容 62 | * 63 | * @param i 64 | * @return 65 | */ 66 | @Override 67 | public Object getGroup(int i) { 68 | return list.get(i).get("txt"); 69 | } 70 | 71 | /** 72 | * 获取一级菜单下第二级菜单的具体的选项的内容 73 | * 74 | * @param i 75 | * @param i1 76 | * @return 77 | */ 78 | @Override 79 | public Object getChild(int i, int i1) { 80 | return text_array[i][i1]; 81 | 82 | } 83 | 84 | /** 85 | * 获取第一级菜单的选项的id 86 | * 87 | * @param i 88 | * @return 89 | */ 90 | @Override 91 | public long getGroupId(int i) { 92 | return i; 93 | } 94 | 95 | /** 96 | * 获取一级菜单下二级菜单选项的id 97 | * 98 | * @param i 99 | * @param i1 100 | * @return 101 | */ 102 | @Override 103 | public long getChildId(int i, int i1) { 104 | return i1; 105 | } 106 | 107 | /** 108 | * 指定位置是否有相应的组视图(指定视图相应的id) 109 | * 110 | * @return 111 | */ 112 | @Override 113 | public boolean hasStableIds() { 114 | return false; 115 | } 116 | 117 | /** 118 | * 对一级菜单的标签的内容进行设置 119 | * 120 | * @param viewGroup 121 | * @return 122 | */ 123 | @Override 124 | public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup viewGroup) { 125 | convertView = convertView.inflate(context, R.layout.item_expandablelist_layout, null); 126 | ImageView imageView = (ImageView) convertView 127 | .findViewById(R.id.img_icon); 128 | TextView textView = (TextView) convertView 129 | .findViewById(R.id.expandablelist_item_txt); 130 | // 是否可以点击扩展开来,设置字体显示的位置 131 | if (isExpanded) { 132 | textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.mipmap.group_down, 0); 133 | } else { 134 | textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.mipmap.group_up, 0); 135 | } 136 | 137 | // 设置图片和字体的内容 138 | imageView.setImageResource(Integer.parseInt(list.get(groupPosition).get("img").toString())); 139 | textView.setText(list.get(groupPosition).get("txt").toString()); 140 | 141 | return convertView; 142 | } 143 | 144 | /** 145 | * 设置一级菜单下二级菜单的内容 146 | * 147 | * @param b 148 | * @param viewGroup 149 | * @return 150 | */ 151 | @Override 152 | public View getChildView(int groupPosition, int childPosition, boolean b, View convertView, ViewGroup viewGroup) { 153 | convertView = convertView.inflate(context, 154 | R.layout.item_expandablelist_child_layout, null); 155 | TextView textView = (TextView) convertView.findViewById(R.id.expandablelist_child_item); 156 | textView.setText(text_array[groupPosition][childPosition]); 157 | return convertView; 158 | } 159 | 160 | /** 161 | * 当选择子节点的时候,调用该方法 162 | * 163 | * @param i 164 | * @param i1 165 | * @return 166 | */ 167 | @Override 168 | public boolean isChildSelectable(int i, int i1) { 169 | return true; 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/adapter/GridViewAdapter.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.BaseAdapter; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import net.anumbrella.menusummary.R; 11 | import net.anumbrella.menusummary.bean.Type; 12 | 13 | import java.util.ArrayList; 14 | 15 | /** 16 | * author:anumbrella 17 | * Date:17/2/23 下午2:32 18 | */ 19 | 20 | public class GridViewAdapter extends BaseAdapter { 21 | 22 | 23 | private Type type; 24 | 25 | private ArrayList listTypes; 26 | 27 | private Context context; 28 | 29 | private Hoder hoder; 30 | 31 | 32 | public GridViewAdapter(Context mContext, ArrayList list) { 33 | this.context = mContext; 34 | this.listTypes = list; 35 | } 36 | 37 | @Override 38 | public int getCount() { 39 | return listTypes.size(); 40 | } 41 | 42 | @Override 43 | public Object getItem(int position) { 44 | return listTypes.get(position); 45 | } 46 | 47 | @Override 48 | public long getItemId(int position) { 49 | return position; 50 | } 51 | 52 | @Override 53 | public View getView(int position, View convertView, ViewGroup viewGroup) { 54 | if (convertView == null) { 55 | convertView = convertView.inflate(context, R.layout.item_gridview, 56 | null); 57 | hoder = new Hoder(convertView); 58 | convertView.setTag(hoder); 59 | } else { 60 | hoder = (Hoder) convertView.getTag(); 61 | } 62 | 63 | if (listTypes != null && listTypes.size() > 0) { 64 | type = listTypes.get(position); 65 | hoder.imageView.setBackgroundResource(type.getIcon()); 66 | hoder.textView.setText(type.getTypeName()); 67 | } 68 | 69 | return convertView; 70 | } 71 | 72 | 73 | private static class Hoder { 74 | private TextView textView; 75 | private ImageView imageView; 76 | public Hoder(View view) { 77 | textView = (TextView) view.findViewById(R.id.typeName_gridView); 78 | imageView = (ImageView) view.findViewById(R.id.icon_gridView); 79 | } 80 | 81 | } 82 | 83 | 84 | } 85 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/bean/Type.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.bean; 2 | 3 | /** 4 | * author:anumbrella 5 | * Date:17/2/23 下午2:31 6 | */ 7 | 8 | public class Type { 9 | 10 | private String typeName; 11 | 12 | private int id; 13 | 14 | private int icon; 15 | 16 | public Type(int id, int icon, String typeName) { 17 | this.typeName = typeName; 18 | this.id = id; 19 | this.icon = icon; 20 | } 21 | 22 | 23 | public String getTypeName() { 24 | 25 | return typeName; 26 | } 27 | 28 | public void setTypeName(String typeName) { 29 | this.typeName = typeName; 30 | } 31 | 32 | public int getId() { 33 | return id; 34 | } 35 | 36 | public void setId(int id) { 37 | this.id = id; 38 | } 39 | 40 | public int getIcon() { 41 | return icon; 42 | } 43 | 44 | public void setIcon(int icon) { 45 | this.icon = icon; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/config/Config.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.config; 2 | 3 | import net.anumbrella.menusummary.R; 4 | 5 | /** 6 | * author:anumbrella 7 | * Date:17/2/23 下午1:51 8 | */ 9 | 10 | public class Config { 11 | 12 | 13 | /** 14 | * 第一个listView的图片资源数组(10张图片) 15 | */ 16 | public static int[] LISTVIEWIMG = new int[]{ 17 | R.mipmap.ic_category_15, R.mipmap.ic_category_20, 18 | R.mipmap.ic_category_25, R.mipmap.ic_category_30, 19 | R.mipmap.ic_category_35, R.mipmap.ic_category_40, 20 | R.mipmap.ic_category_45, R.mipmap.ic_category_50, 21 | R.mipmap.ic_category_55, R.mipmap.ic_category_60 22 | }; 23 | /** 24 | * 第一个listView的文本数据数组(10个数据文本) 25 | */ 26 | public static String[] LISTVIEWTXT = new String[]{"热门分类", "美食", "购物", 27 | "休闲娱乐", "运动健身", "丽人", "结婚", "酒店", "爱车", "亲子"}; 28 | 29 | 30 | /** 31 | * 第二个listView文本数据数组(10,..) 32 | */ 33 | public static String[][] MORELISTVIEWTXT = new String[][]{ 34 | {"全部分类", "小吃快餐", "咖啡厅", "电影院", "KTV", "茶馆", "足疗按摩", "超市/便利店", 35 | "银行", "经济型酒店", "景点/郊游", "公园", "美发"}, 36 | {"全部美食", "小吃快餐", "西餐", "火锅", "北京菜", "川菜", "日本", "面包甜点", "粤菜", 37 | "韩国料理", "自助餐", "浙江菜", "云南菜", "湘菜", "东南亚菜", "西北菜", "鲁菜", 38 | "东北菜", "素菜", "新疆菜", "海鲜", "清真菜", "贵州菜", "湖北菜", "其他"}, 39 | {"全部购物", "综合商场", "服饰鞋包", "超市/便利店", "特色集市", "品牌折扣店", "眼镜店", "珠宝饰品", 40 | "化妆品", "运动户外", "食品茶酒", "书店", "数码产品", "药店", "京味儿购物", "亲子购物", 41 | "花店", "家具建材", "更多购物场所"}, 42 | {"全部休闲娱乐", "咖啡厅", "KTV", "景点/郊游", "电影院", "酒吧", "公园", "温泉", "文化艺术", 43 | "足疗按摩", "洗浴", "茶馆", "游乐游艺", "密室", "采摘/农家乐", "桌面游戏", "台球馆", 44 | "DIY手工坊", "休闲网吧", "真人CS", "棋牌室", "轰趴馆", "私人影院", "更多休闲娱乐"}, 45 | {"全部运动健身", "健身中心", "游泳馆", "瑜伽", "羽毛球馆", "台球馆", "舞蹈", "体育场馆", 46 | "高尔夫场", "网球场", "武术场馆", "篮球场", "保龄球馆", "足球场", "乒乓球馆", 47 | "更多体育运动"}, 48 | {"全部丽人", "美发", "美容/SPA", "齿科", "美甲", "化妆品", "瑜伽", "瘦身纤体", "舞蹈", 49 | "个性写真", "整形"}, 50 | {"全部结婚", "婚纱摄影", "婚宴酒店", "婚纱礼服", "婚庆公司", "婚戒首饰", "个性写真", "彩妆造型", 51 | "婚礼小礼品", "婚礼跟拍", "婚车租赁", "司仪主持", "婚房装修", "更多婚礼服务"}, 52 | {"全部酒店", "经济型酒店", "五星级酒店", "度假村", "四星级酒店", "三星级酒店", "农家院", 53 | "公寓式酒店", "青年旅社", "精品酒店", "更多酒店住宿"}, 54 | {"全部爱车", "维修保养", "驾校", "停车场", "4S店/汽车销售", "加油站", "配件/车饰", "汽车租赁", 55 | "汽车保险"}, 56 | {"全部亲子", "亲子摄影", "幼儿教育", "亲子游乐", "孕产护理", "亲子购物", "更多亲子服务"} 57 | }; 58 | 59 | 60 | /** 61 | * 数组的大小为(28) 62 | */ 63 | public static String[] list = new String[]{"特价", "潮流女装", "品牌男装", 64 | "内衣配饰", "精品童装", "家用电器", "手机数码", "电脑办公", "个护化妆", "母婴频道", "美食", "海鲜", 65 | "家居家纺", "整车车品", "鞋靴箱包", "运动户外", "图书", "玩具乐器", "钟表", "居家生活", "珠宝饰品", 66 | "音像制品", "家具建材", "计生情趣", "营养保健", "奢侈礼品", "生活服务", "旅游出行" 67 | }; 68 | 69 | /** 70 | * 数组的大小为(28) 71 | */ 72 | public static int[] iconList = new int[]{R.mipmap.tejia, 73 | R.mipmap.nvzhuang, R.mipmap.nanzhuang, R.mipmap.nanzhuang, 74 | R.mipmap.tongzhuang, R.mipmap.dianqi, R.mipmap.dianqi, 75 | R.mipmap.dianqi, R.mipmap.jiaju, R.mipmap.muying, 76 | R.mipmap.meishi, R.mipmap.haixian, R.mipmap.jiaju, 77 | R.mipmap.jiaju, R.mipmap.nvzhuang, R.mipmap.nanzhuang, 78 | R.mipmap.shipin, R.mipmap.shipin, R.mipmap.zhongbiao, 79 | R.mipmap.zhongbiao, R.mipmap.shipin, R.mipmap.jiaju, 80 | R.mipmap.zhongbiao, R.mipmap.dianqi, R.mipmap.zhongbiao, 81 | R.mipmap.zhongbiao, R.mipmap.zhongbiao, R.mipmap.zhongbiao 82 | }; 83 | 84 | 85 | /** 86 | * 父目录ExpandleableListView的文本数据数组(4) 87 | */ 88 | public static String[] EXPANDABLE_LISTVIEW_TXT = new String[]{"热门分类", 89 | "美食", "购物", "家装"}; 90 | 91 | 92 | /** 93 | * 父目录ExpandableListView的图片资源数组(4) 94 | */ 95 | public static int[] EXPANDABLE_LISTVIEW_IMG = new int[]{ 96 | R.mipmap.ic_category_15, R.mipmap.ic_category_20, 97 | R.mipmap.ic_category_30, R.mipmap.ic_category_35 98 | }; 99 | 100 | /** 101 | * 子目录ExpandleableListView的文本数据数组(4,4) 102 | */ 103 | public static String[][] EXPANDABLE_MORELISTVIEW_TXT = new String[][]{ 104 | {"全部分类", "小吃快餐", "咖啡厅", "电影院", "KTV", "茶馆", "足疗按摩", "超市/便利店", 105 | "银行", "经济型酒店", "景点/郊游", "公园", "美发"}, 106 | {"全部美食", "小吃快餐", "西餐", "火锅", "北京菜", "川菜", "日本", "面包甜点", "粤菜", 107 | "韩国料理", "自助餐", "浙江菜", "云南菜", "湘菜", "东南亚菜", "西北菜", "鲁菜", 108 | "东北菜", "素菜", "新疆菜", "海鲜", "清真菜", "贵州菜", "湖北菜", "其他"}, 109 | {"全部购物", "综合商场", "服饰鞋包", "超市/便利店", "特色集市", "品牌折扣店", "眼镜店", "珠宝饰品", 110 | "化妆品", "运动户外", "食品茶酒", "书店", "数码产品", "药店", "京味儿购物", "亲子购物", 111 | "花店", "家具建材", "更多购物场所"}, 112 | {"全部家装", "家具家装", "家用电器", "建材", "家装卖场", "装修设计"} 113 | }; 114 | 115 | 116 | /** 117 | * 父目录ExpandableGridView的文本数据数组(14) 118 | */ 119 | public static String[] EXPANDABLE_GRIDVIEW_TXT = new String[]{"新闻", "军事", 120 | "微博", "体育", "娱乐", "财经", "视频", "科技", "图片", "房产", "汽车", "教育", "历史", 121 | "女性" 122 | }; 123 | 124 | 125 | /** 126 | * 子目录ExpandableGridView的文本数据(14,..) 127 | */ 128 | public static String[][] EXPANDABLE_MOREGRIDVIEW_TXT = { 129 | {"国内", "社会", "国际", "评论", "传媒", "排行", "视频", "滚动", "调查", "搜索", "航空", 130 | "直播"}, 131 | {"新闻", "图片", "中国军情", "专栏", "视频"}, 132 | {"注册", "名人堂", "人气热榜", "客户端", "热门微博", "随便看看"}, 133 | {"NBA", "中超", "欧冠", "英超", "意甲", "西甲", "德甲", "CBA", "彩票", "网球", 134 | "高尔夫", "综合", "图片", "赛车", "国足", "中甲", "田径"}, 135 | {"明星", "电影", "电视", "音乐", "韩娱", "毒蛇女", "八卦", "水煮娱", "博客", "影视打分"}, 136 | {"产经", "消费", "理财", "外汇", "股票", "行情", "基金", "美股", "港股", "期货", "黄金", 137 | "投资助手", "银行", "保险", "专栏", "博客", "股吧", "图集", "自选股"}, 138 | {"新闻", "娱乐", "综艺", "体育", "搞笑"}, 139 | {"互联网", "电信", "软件", "硬件", "创事记", "探索", "苹果汇", "数码", "创业", "手机", 140 | "相机", "趣图", "笔记本"}, 141 | {"看见", "天下", "奇趣", "历史", "摄影师"}, 142 | {"新房", "二手房", "租房", "家居", "最新开盘", "打折优惠", "看房图", "新闻", "资讯", "装修"}, 143 | {"车型", "报价", "图赏", "保养", "二手车", "新车", "降价", "导购", "试车", "答题"}, 144 | {"高考", "考研", "留学", "外语", "图片", "国际校", "中小学", "公务员", "博客", "专栏", 145 | "滚动", "高校库"}, 146 | {"解密", "党史", "战争", "野史", "资讯", "图片", "专题"}, 147 | {"情感", "美容", "八卦", "美图", "试用", "口述", "直播"} 148 | }; 149 | 150 | 151 | } 152 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/fragment/TypeFragment.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.AdapterView; 10 | import android.widget.GridView; 11 | import android.widget.TextView; 12 | 13 | import net.anumbrella.menusummary.R; 14 | import net.anumbrella.menusummary.adapter.GridViewAdapter; 15 | import net.anumbrella.menusummary.bean.Type; 16 | import net.anumbrella.menusummary.config.Config; 17 | import net.anumbrella.menusummary.utils.ToastUtils; 18 | 19 | import java.util.ArrayList; 20 | 21 | /** 22 | * author:anumbrella 23 | * Date:17/2/23 下午2:27 24 | */ 25 | 26 | public class TypeFragment extends Fragment { 27 | 28 | 29 | private ArrayList listType; 30 | /** 31 | * widget网格view 32 | */ 33 | private GridView gridView; 34 | /** 35 | * 网格适配器 36 | */ 37 | private GridViewAdapter adapter; 38 | 39 | /** 40 | * 右侧栏目中的子选项 41 | */ 42 | private Type type; 43 | 44 | /** 45 | * 子选项名称 46 | */ 47 | private String typeName; 48 | 49 | /** 50 | * 图片 51 | */ 52 | private int icon; 53 | 54 | 55 | @Override 56 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 57 | View view = inflater.inflate(R.layout.detaillist_layout, null); 58 | 59 | gridView = (GridView) view.findViewById(R.id.GridViewList); 60 | 61 | int index = getArguments().getInt("index"); 62 | 63 | typeName = Config.list[index]; 64 | icon = Config.iconList[index]; 65 | 66 | ((TextView) view.findViewById(R.id.TypeName)).setText(typeName); 67 | 68 | // 为listType装载数据 69 | setTypeList(); 70 | 71 | adapter = new GridViewAdapter(getActivity(), listType); 72 | gridView.setAdapter(adapter); 73 | gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 74 | 75 | @Override 76 | public void onItemClick(AdapterView parent, View view, int position, long id) { 77 | String typeName = listType.get(position).getTypeName(); 78 | ToastUtils.showToast("你点击的是" + typeName); 79 | 80 | } 81 | }); 82 | return view; 83 | } 84 | 85 | /** 86 | * 给listType设定数据 87 | */ 88 | private void setTypeList() { 89 | listType = new ArrayList(); 90 | // 这里可以根据数据设定要填充的资源 91 | for (int i = 0; i < 23; i++) { 92 | type = new Type(i, icon, typeName + i); 93 | listType.add(type); 94 | } 95 | 96 | } 97 | 98 | 99 | } 100 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/utils/AppUtils.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.utils; 2 | 3 | import android.content.Context; 4 | import android.content.res.AssetManager; 5 | import android.content.res.Resources; 6 | import android.os.Handler; 7 | import android.os.Looper; 8 | 9 | /** 10 | * author:anumbrella 11 | * Date:17/2/16 下午1:59 12 | */ 13 | 14 | public class AppUtils { 15 | 16 | private static Context mContext; 17 | 18 | private static Thread mUiThread; 19 | 20 | private static Handler sHandler = new Handler(Looper.getMainLooper()); 21 | 22 | public static void init(Context context) { 23 | mContext = context; 24 | mUiThread = Thread.currentThread(); 25 | } 26 | 27 | 28 | public static Context getAppContext() { 29 | return mContext; 30 | } 31 | 32 | public static AssetManager getAssets() { 33 | return mContext.getAssets(); 34 | } 35 | 36 | public static Resources getResource() { 37 | return mContext.getResources(); 38 | } 39 | 40 | public static boolean isUIThread() { 41 | return Thread.currentThread() == mUiThread; 42 | } 43 | 44 | public static void runOnUI(Runnable r) { 45 | sHandler.post(r); 46 | } 47 | 48 | public static void runOnUIDelayed(Runnable r, long delayMills) { 49 | sHandler.postDelayed(r, delayMills); 50 | } 51 | 52 | public static void removeRunnable(Runnable r) { 53 | if (r == null) { 54 | sHandler.removeCallbacksAndMessages(null); 55 | } else { 56 | sHandler.removeCallbacks(r); 57 | } 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/utils/ToastUtils.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.utils; 2 | 3 | import android.content.Context; 4 | import android.widget.Toast; 5 | 6 | /** 7 | * author:anumbrella 8 | * Date:17/2/16 下午1:55 9 | */ 10 | 11 | public class ToastUtils { 12 | 13 | private static Toast mToast; 14 | 15 | private static Context context = AppUtils.getAppContext(); 16 | 17 | 18 | /********************** 19 | * 非连续弹出的Toast 20 | ***********************/ 21 | 22 | 23 | public static void showSingleToast(int resId) { 24 | getSingleToast(resId, Toast.LENGTH_SHORT).show(); 25 | } 26 | 27 | public static void showSingleToast(String text) { 28 | getSingleToast(text, Toast.LENGTH_SHORT).show(); 29 | } 30 | 31 | public static void showSingleLongToast(int resId) { 32 | getSingleToast(resId, Toast.LENGTH_LONG).show(); 33 | } 34 | 35 | public static void showSingleLongToast(String text) { 36 | getSingleToast(text, Toast.LENGTH_LONG).show(); 37 | } 38 | 39 | 40 | /*********************** 41 | * 连续弹出的Toast 42 | ************************/ 43 | 44 | public static void showToast(int resId) { 45 | getToast(resId, Toast.LENGTH_SHORT).show(); 46 | } 47 | 48 | public static void showToast(String text) { 49 | getToast(text, Toast.LENGTH_SHORT).show(); 50 | } 51 | 52 | public static void showLongToast(int resId) { 53 | getToast(resId, Toast.LENGTH_LONG).show(); 54 | } 55 | 56 | public static void showLongToast(String text) { 57 | getToast(text, Toast.LENGTH_LONG).show(); 58 | } 59 | 60 | 61 | /** 62 | * 连续调用不会连续弹出,只是替换文本 63 | * 64 | * @param resId 65 | * @param duration 66 | * @return 67 | */ 68 | public static Toast getSingleToast(int resId, int duration) { 69 | return getSingleToast(context.getResources().getText(resId).toString(), duration); 70 | } 71 | 72 | 73 | public static Toast getSingleToast(String text, int duration) { 74 | if (mToast == null) { 75 | mToast = Toast.makeText(context, text, duration); 76 | } else { 77 | mToast.setText(text); 78 | } 79 | return mToast; 80 | } 81 | 82 | /** 83 | * 连续调用会连续弹出 84 | * 85 | * @param resId 86 | * @param duration 87 | * @return 88 | */ 89 | public static Toast getToast(int resId, int duration) { 90 | return getToast(context.getResources().getText(resId).toString(), duration); 91 | } 92 | 93 | public static Toast getToast(String text, int duration) { 94 | return Toast.makeText(context, text, duration); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /demo/src/main/java/net/anumbrella/menusummary/widget/MyGridView.java: -------------------------------------------------------------------------------- 1 | package net.anumbrella.menusummary.widget; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.widget.GridView; 6 | 7 | /** 8 | * author:anumbrella 9 | * Date:17/2/23 下午3:40 10 | * 自定义的视图显示(GridView) 11 | */ 12 | 13 | public class MyGridView extends GridView { 14 | 15 | public MyGridView(Context context, AttributeSet attrs) { 16 | super(context, attrs); 17 | } 18 | 19 | 20 | /** 21 | * 设置视图不滚动 22 | * 23 | * @param widthMeasureSpec 24 | * @param heightMeasureSpec 25 | */ 26 | @Override 27 | public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 28 | int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, 29 | MeasureSpec.AT_MOST); 30 | super.onMeasure(widthMeasureSpec, expandSpec); 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable/text_item_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable/text_item_top_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /demo/src/main/res/layout/activity_classifymenu_layout.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 13 | 14 |