Przeglądaj źródła

Optimize MainActivity => replace ListView with ExpandableListView

An An 4 lat temu
rodzic
commit
06d6128783

+ 359 - 306
sample/src/main/java/com/github/aachartmodel/aainfographics/demo/basiccontent/MainActivity.kt

@@ -1,357 +1,410 @@
-/**
- * ◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉ ...... SOURCE CODE ......◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉
- * ◉◉◉...................................................       ◉◉◉
- * ◉◉◉   https://github.com/AAChartModel/AAChartCore            ◉◉◉
- * ◉◉◉   https://github.com/AAChartModel/AAChartCore-Kotlin     ◉◉◉
- * ◉◉◉...................................................       ◉◉◉
- * ◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉ ...... SOURCE CODE ......◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉
- */
-
-/**
-
- * -------------------------------------------------------------------------------
- *
- *  🌕 🌖 🌗 🌘  ❀❀❀   WARM TIPS!!!   ❀❀❀ 🌑 🌒 🌓 🌔
- *
- * Please contact me on GitHub,if there are any problems encountered in use.
- * GitHub Issues : https://github.com/AAChartModel/AAChartCore-Kotlin/issues
- * -------------------------------------------------------------------------------
- * And if you want to contribute for this project, please contact me as well
- * GitHub        : https://github.com/AAChartModel
- * StackOverflow : https://stackoverflow.com/users/7842508/codeforu
- * JianShu       : http://www.jianshu.com/u/f1e6753d4254
- * SegmentFault  : https://segmentfault.com/u/huanghunbieguan
- *
- * -------------------------------------------------------------------------------
-
- */
 package com.github.aachartmodel.aainfographics.demo.basiccontent
-
 import android.content.Intent
 import android.os.Bundle
-import android.view.View
-import android.widget.AdapterView.OnItemClickListener
-import android.widget.ArrayAdapter
-import android.widget.ListView
+import android.widget.ExpandableListView
+import android.widget.Toast
 import androidx.appcompat.app.AppCompatActivity
 import com.github.aachartmodel.aainfographics.aachartcreator.AAChartType
 import com.github.aachartmodel.aainfographics.demo.R
 import com.github.aachartmodel.aainfographics.demo.additionalcontent.*
 
 class MainActivity : AppCompatActivity() {
-
-    private val data = arrayOf(
-        /*基础类型图表*/
-        "/*基础类型图表*/Column Chart---柱形图--------------",
-        "Bar Chart---条形图",
-        "Area Chart---折线填充图",
-        "Areaspline Chart---曲线填充图",
-        "Step Area Chart--- 直方折线填充图",
-        "Step Line Chart--- 直方折线图",
-        "Line Chart---折线图",
-        "Spline Chart---曲线图",
-        /*特殊类型图表*/
-        "/*特殊类型图表*/Polar Chart---极地图图-------------",
-        "Pie Chart---扇形图",
-        "Bubble Chart---气泡图",
-        "Scatter Chart---散点图",
-        "Arearange Chart---区域范围图",
-        "Columnrange Chart--- 柱形范围图",
-        "Step Line Chart--- 直方折线图",
-        "Step Area Chart--- 直方折线填充图",
-        "Boxplot Chart--- 箱线图",
-        "Waterfall Chart--- 瀑布图",
-        "Pyramid Chart---金字塔图",
-        "Funnel Chart---漏斗图",
-        "Errorbar Chart---误差图",
-        /*Mixed Chart---混合图*/
-        "/*Mixed Chart---混合图*/arearangeMixedLine-----------------",
-        "columnrangeMixedLine",
-        "stackingColumnMixedLine",
-        "dashStyleTypeMixed",
-        "negativeColorMixed",
-        "scatterMixedLine",
-        "negativeColorMixedBubble",
-        "polygonMixedScatter",
-        "polarChartMixed",
-        /*自定义样式图表*/
-        "/*自定义样式图表*/colorfulChart-----------------",
-        "gradientColorfulChart",
-        "discontinuousDataChart",
-        "colorfulColumnChart",
-        "nightingaleRoseChart",
-        "chartWithShadowStyle",
-        "colorfulGradientAreaChart",
-        "colorfulGradientSplineChart",
-        "gradientColorAreasplineChart",
-        "SpecialStyleMarkerOfSingleDataElementChart",
-        "SpecialStyleColumnOfSingleDataElementChart",
-        "AreaChartThreshold",
-        "customScatterChartMarkerSymbolContent",
-        "customLineChartMarkerSymbolContent",
-        "TriangleRadarChart",
-        "QuadrangleRadarChart",
-        "PentagonRadarChart",
-        "HexagonRadarChart",
-        /*使用AAOptions绘制图表*/
-        "/*使用AAOptions绘制图表*/customLegendStyle-----------------",
-        "drawChartWithOptionsOne",
-        "AAPlotLinesForChart",
-        "customAATooltipWithJSFunction",
-        "customXAxisCrosshairStyle",
-        "XAxisLabelsFontColorWithHTMLString",
-        "XAxisLabelsFontColorAndFontSizeWithHTMLString",
-        "_DataLabels_XAXis_YAxis_Legend_Style",
-        "XAxisPlotBand",
-        "configureTheMirrorColumnChart",
-        "configureDoubleYAxisChartOptions",
-        "configureTripleYAxesMixedChart",
-        "customLineChartDataLabelsFormat",
-        "configureDoubleYAxesAndColumnLineMixedChart",
-        "configureDoubleYAxesMarketDepthChart",
-        "customAreaChartTooltipStyleLikeHTMLTable",
-        "simpleGaugeChart",
-        "gaugeChartWithPlotBand",
-        /*即时刷新📈📊图表数据*/
-        /*即时刷新📈📊图表数据*/"/*即时刷新📈📊图表数据*/Column Chart---柱形图--------------",
-        "Bar Chart---条形图",
-        "Area Chart---折线填充图",
-        "Areaspline Chart---曲线填充图",
-        "Step Area Chart--- 直方折线填充图",
-        "Step Line Chart--- 直方折线图",
-        "Line Chart---折线图",
-        "Spline Chart---曲线图",
-        "Scatter Chart---散点图",
-        /*自定义 formatter 函数*/
-        "/*自定义 formatter 函数*/简单字符串拼接-----------------",
-        "自定义不同单位后缀",
-        "值为0时,在tooltip中不显示",
-        "自定义多彩颜色文字",
-        "自定义箱线图的浮动提示框头部内容",
-        "自定义Y轴文字",
-        "自定义Y轴文字2",
-        "自定义分组堆积柱状图tooltip内容",
-        "双 X 轴镜像图表",
-        "customArearangeChartTooltip",
-        "调整折线图的 X 轴左边距",
-        "通过来自外部的数据源来自定义 tooltip (而非常规的来自图表的 series)",
-        /*执行由 JavaScript 字符串映射转换成的 js function 函数*/
-        "evalJSFunction1",
-        "evalJSFunction2",
-        "evalJSFunction3",
-        /*Double Charts Linked Work---双表联动*/
-        "doubleChartsLinkedWork----------------------------"
-
-    )
-
-    private var chartTypeArr = arrayOf(
-        /*基础类型图表*/
-        AAChartType.Column.value,
-        AAChartType.Bar.value,
-        AAChartType.Area.value,
-        AAChartType.Areaspline.value,
-        AAChartType.Area.value,
-        AAChartType.Line.value,
-        AAChartType.Line.value,
-        AAChartType.Spline.value,
-        /*特殊类型图表*/
-        AAChartType.Column.value,
-        AAChartType.Pie.value,
-        AAChartType.Bubble.value,
-        AAChartType.Scatter.value,
-        AAChartType.Arearange.value,
-        AAChartType.Columnrange.value,
-        AAChartType.Line.value,
-        AAChartType.Area.value,
-        AAChartType.Boxplot.value,
-        AAChartType.Waterfall.value,
-        AAChartType.Pyramid.value,
-        AAChartType.Funnel.value,
-        AAChartType.Errorbar.value,
-        /*Mixed Chart---混合图*/
-        "arearangeMixedLine",
-        "columnrangeMixedLine",
-        "stackingColumnMixedLine",
-        "dashStyleTypeMixed",
-        "negativeColorMixed",
-        "scatterMixedLine",
-        "negativeColorMixedBubble",
-        "polygonMixedScatter",
-        "polarChartMixed",
-        /*自定义样式图表*/
-        "colorfulChart",
-        "gradientColorfulChart",
-        "discontinuousDataChart",
-        "colorfulColumnChart",
-        "nightingaleRoseChart",
-        "chartWithShadowStyle",
-        "colorfulGradientAreaChart",
-        "colorfulGradientSplineChart",
-        "gradientColorAreasplineChart",
-        "SpecialStyleMarkerOfSingleDataElementChart",
-        "SpecialStyleColumnOfSingleDataElementChart",
-        "AreaChartThreshold",
-        "customScatterChartMarkerSymbolContent",
-        "customLineChartMarkerSymbolContent",
-        "TriangleRadarChart",
-        "QuadrangleRadarChart",
-        "PentagonRadarChart",
-        "HexagonRadarChart",
-        /*使用AAOptions绘制图表*/
-        "customLegendStyle",
-        "AAPlotBandsForChart",
-        "AAPlotLinesForChart",
-        "customAATooltipWithJSFunction",
-        "customXAxisCrosshairStyle",
-        "XAxisLabelsFontColorWithHTMLString",
-        "XAxisLabelsFontColorAndFontSizeWithHTMLString",
-        "_DataLabels_XAXis_YAxis_Legend_Style",
-        "XAxisPlotBand",
-        "configureTheMirrorColumnChart",
-        "configureDoubleYAxisChartOptions",
-        "configureTripleYAxesMixedChart",
-        "customLineChartDataLabelsFormat",
-        "configureDoubleYAxesAndColumnLineMixedChart",
-        "configureDoubleYAxesMarketDepthChart",
-        "customAreaChartTooltipStyleLikeHTMLTable",
-        "simpleGaugeChart",
-        "gaugeChartWithPlotBand",
-        /*即时刷新📈📊图表数据*/
-        AAChartType.Column.value,
-        AAChartType.Bar.value,
-        AAChartType.Area.value,
-        AAChartType.Areaspline.value,
-        AAChartType.Area.value,
-        AAChartType.Line.value,
-        AAChartType.Line.value,
-        AAChartType.Spline.value,
-        AAChartType.Scatter.value,
-        /*自定义 formatter 函数*/
-        "customAreaChartTooltipStyleWithSimpleFormatString",
-        "customAreaChartTooltipStyleWithDifferentUnitSuffix",
-        "customAreaChartTooltipStyleWithColorfulHtmlLabels",
-        "customLineChartTooltipStyleWhenValueBeZeroDoNotShow",
-        "customBoxplotTooltipContent",
-        "customYAxisLabels",
-        "customYAxisLabels2",
-        "customStackedAndGroupedColumnChartTooltip",
-        "customDoubleXAxesChart",
-        "customArearangeChartTooltip",
-        "customLineChartOriginalPointPositionByConfiguringXAxisFormatterAndTooltipFormatter",
-        "customTooltipWhichDataSourceComeFromOutSideRatherThanSeries",
-        /*执行由 JavaScript 字符串映射转换成的 js function 函数*/
-        "evalJSFunction1",
-        "evalJSFunction2",
-        "evalJSFunction3",
-        /*Double Charts Linked Work---双表联动*/
-        "doubleChartsLinkedWork"
-    )
-
+    private val chartTypeNameArr =
+        arrayOf(
+            arrayOf(
+                "Column Chart---柱形图",
+                "Bar Chart---条形图",
+                "Area Chart---折线填充图",
+                "Areaspline Chart---曲线填充图",
+                "Step Area Chart--- 直方折线填充图",
+                "Step Line Chart--- 直方折线图",
+                "Line Chart---折线图",
+                "Spline Chart---曲线图"
+            ), arrayOf(
+                "Polar Chart---极地图图",
+                "Pie Chart---扇形图",
+                "Bubble Chart---气泡图",
+                "Scatter Chart---散点图",
+                "Arearange Chart---区域范围图",
+                "Columnrange Chart--- 柱形范围图",
+                "Step Line Chart--- 直方折线图",
+                "Step Area Chart--- 直方折线填充图",
+                "Boxplot Chart--- 箱线图",
+                "Waterfall Chart--- 瀑布图",
+                "Pyramid Chart---金字塔图",
+                "Funnel Chart---漏斗图",
+                "Errorbar Chart---误差图"
+            ), arrayOf(
+                "arearangeMixedLine",
+                "columnrangeMixedLine",
+                "stackingColumnMixedLine",
+                "dashStyleTypeMixed",
+                "negativeColorMixed",
+                "scatterMixedLine",
+                "negativeColorMixedBubble",
+                "polygonMixedScatter",
+                "polarChartMixed"
+            ), arrayOf(
+                "colorfulChart",
+                "gradientColorfulChart",
+                "discontinuousDataChart",
+                "colorfulColumnChart",
+                "nightingaleRoseChart",
+                "chartWithShadowStyle",
+                "colorfulGradientAreaChart",
+                "colorfulGradientSplineChart",
+                "gradientColorAreasplineChart",
+                "SpecialStyleMarkerOfSingleDataElementChart",
+                "SpecialStyleColumnOfSingleDataElementChart",
+                "AreaChartThreshold",
+                "customScatterChartMarkerSymbolContent",
+                "customLineChartMarkerSymbolContent",
+                "TriangleRadarChart",
+                "QuadrangleRadarChart",
+                "PentagonRadarChart",
+                "HexagonRadarChart",
+                "adjustYAxisMaxAndMinValues---调整 X 轴和 Y 轴最大值",
+                "custom Special Style DataLabel Of Single Data Element Chart---指定单个数据元素的 DataLabel 为特殊样式",
+                "custom Bar Chart Hover Color and Select Colorc---自定义条形图手指滑动颜色和单个长条被选中颜色",
+                "custom Line Chart Chart Hover And Select Halo Style---自定义直线图手指略过和选中的 Halo 样式",
+                "custom Spline Chart Marker States Hover Style---自定义曲线图手指略过时的 Marker 样式",
+                "customNormalStackingChartDataLabelsContentAndStyle---自定义堆积柱状图 DataLabels 的内容及样式",
+                "upsideDownPyramidChart---倒立的金字塔图",
+                "doubleLayerPieChart---双层嵌套扇形图",
+                "disableSomeOfLinesMouseTrackingEffect---针对部分数据列关闭鼠标或手指跟踪行为",
+                "configureColorfulShadowChart---彩色阴影效果的曲线图",
+                "configureColorfulDataLabelsStepLineChart---彩色 DataLabels 的直方折线图",
+                "configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart---彩色渐变效果且彩色 DataLabels 的直方折线填充图",
+                "disableSplineChartMarkerHoverEffect---禁用曲线图的手指滑动 marker 点的光圈变化放大的效果",
+                "Top Rounded Corners Stacking Column Chart---顶部为圆角的堆积柱状图"
+            ), arrayOf(
+                "customLegendStyle",
+                "drawChartWithOptionsOne",
+                "AAPlotLinesForChart",
+                "customAATooltipWithJSFunction",
+                "customXAxisCrosshairStyle",
+                "XAxisLabelsFontColorWithHTMLString",
+                "XAxisLabelsFontColorAndFontSizeWithHTMLString",
+                "_DataLabels_XAXis_YAxis_Legend_Style",
+                "XAxisPlotBand",
+                "configureTheMirrorColumnChart",
+                "configureDoubleYAxisChartOptions",
+                "configureTripleYAxesMixedChart",
+                "customLineChartDataLabelsFormat",
+                "configureDoubleYAxesAndColumnLineMixedChart",
+                "configureDoubleYAxesMarketDepthChart",
+                "customAreaChartTooltipStyleLikeHTMLTable",
+                "simpleGaugeChart",
+                "gaugeChartWithPlotBand"
+            ), arrayOf(
+                "Column Chart---柱形图",
+                "Bar Chart---条形图",
+                "Area Chart---折线填充图",
+                "Areaspline Chart---曲线填充图",
+                "Step Area Chart--- 直方折线填充图",
+                "Step Line Chart--- 直方折线图",
+                "Line Chart---折线图",
+                "Spline Chart---曲线图",
+                "Scatter Chart---散点图"
+            ), arrayOf(
+                "简单字符串拼接",
+                "自定义不同单位后缀",
+                "自定义多彩颜色文字",
+                "值为0时,在tooltip中不显示",
+                "自定义箱线图的浮动提示框头部内容",
+                "自定义Y轴文字",
+                "自定义Y轴文字2",
+                "自定义分组堆积柱状图tooltip内容",
+                "双 X 轴镜像图表",
+                "customArearangeChartTooltip---自定义折线范围图的tooltip",
+                "调整折线图的 X 轴左边距",
+                "通过来自外部的数据源来自定义 tooltip (而非常规的来自图表的 series)"
+            ), arrayOf(
+                "eval JS function 1",
+                "eval JS function 2",
+                "eval JS function 3"
+            ), arrayOf(
+                "doubleChartsLinkedWork"
+            ), arrayOf(
+                "Column Chart---柱形图",
+                "Bar Chart---条形图",
+                "Area Chart---折线填充图",
+                "Areaspline Chart---曲线填充图",
+                "Step Area Chart--- 直方折线填充图",
+                "Step Line Chart--- 直方折线图",
+                "Line Chart---折线图",
+                "Spline Chart---曲线图"
+            )
+        )
+    var chartTypeArr =
+        arrayOf(
+            arrayOf( /*基础类型图表*/
+                AAChartType.Column.value,
+                AAChartType.Bar.value,
+                AAChartType.Area.value,
+                AAChartType.Areaspline.value,
+                AAChartType.Area.value,
+                AAChartType.Line.value,
+                AAChartType.Line.value,
+                AAChartType.Spline
+            ), arrayOf( /*特殊类型图表*/
+                AAChartType.Column.value,
+                AAChartType.Pie.value,
+                AAChartType.Bubble.value,
+                AAChartType.Scatter.value,
+                AAChartType.Arearange.value,
+                AAChartType.Columnrange.value,
+                AAChartType.Line.value,
+                AAChartType.Area.value,
+                AAChartType.Boxplot.value,
+                AAChartType.Waterfall.value,
+                AAChartType.Pyramid.value,
+                AAChartType.Funnel.value,
+                AAChartType.Errorbar.value
+            ), arrayOf( /*Mixed Chart---混合图*/
+                "arearangeMixedLine",
+                "columnrangeMixedLine",
+                "stackingColumnMixedLine",
+                "dashStyleTypeMixed",
+                "negativeColorMixed",
+                "scatterMixedLine",
+                "negativeColorMixedBubble",
+                "polygonMixedScatter",
+                "polarChartMixed"
+            ), arrayOf( /*自定义样式图表*/
+                "colorfulChart",
+                "gradientColorfulChart",
+                "discontinuousDataChart",
+                "colorfulColumnChart",
+                "nightingaleRoseChart",
+                "chartWithShadowStyle",
+                "colorfulGradientAreaChart",
+                "colorfulGradientSplineChart",
+                "gradientColorAreasplineChart",
+                "SpecialStyleMarkerOfSingleDataElementChart",
+                "SpecialStyleColumnOfSingleDataElementChart",
+                "AreaChartThreshold",
+                "customScatterChartMarkerSymbolContent",
+                "customLineChartMarkerSymbolContent",
+                "TriangleRadarChart",
+                "QuadrangleRadarChart",
+                "PentagonRadarChart",
+                "HexagonRadarChart",
+                "adjustYAxisMaxAndMinValues",
+                "customSpecialStyleDataLabelOfSingleDataElementChart",
+                "customBarChartHoverColorAndSelectColor",
+                "customChartHoverAndSelectHaloStyle",
+                "customSplineChartMarkerStatesHoverStyle",
+                "customNormalStackingChartDataLabelsContentAndStyle",
+                "upsideDownPyramidChart",
+                "doubleLayerPieChart",
+                "disableSomeOfLinesMouseTrackingEffect",
+                "configureColorfulShadowSplineChart",
+                "configureColorfulDataLabelsStepLineChart",
+                "configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart",
+                "disableSplineChartMarkerHoverEffect",
+                "topRoundedCornersStackingColumnChart"
+            ), arrayOf( /*使用AAOptions绘制图表*/
+                "customLegendStyle",
+                "AAPlotBandsForChart",
+                "AAPlotLinesForChart",
+                "customAATooltipWithJSFunction",
+                "customXAxisCrosshairStyle",
+                "XAxisLabelsFontColorWithHTMLString",
+                "XAxisLabelsFontColorAndFontSizeWithHTMLString",
+                "_DataLabels_XAXis_YAxis_Legend_Style",
+                "XAxisPlotBand",
+                "configureTheMirrorColumnChart",
+                "configureDoubleYAxisChartOptions",
+                "configureTripleYAxesMixedChart",
+                "customLineChartDataLabelsFormat",
+                "configureDoubleYAxesAndColumnLineMixedChart",
+                "configureDoubleYAxesMarketDepthChart",
+                "customAreaChartTooltipStyleLikeHTMLTable",
+                "simpleGaugeChart",
+                "gaugeChartWithPlotBand"
+            ), arrayOf( /*即时刷新📈📊图表数据*/
+                AAChartType.Column.value,
+                AAChartType.Bar.value,
+                AAChartType.Area.value,
+                AAChartType.Areaspline.value,
+                "stepArea",
+                "stepLine",
+                AAChartType.Line.value,
+                AAChartType.Spline.value,
+                AAChartType.Scatter.value
+            ), arrayOf( /*自定义 formatter 函数*/
+                "customAreaChartTooltipStyleWithSimpleFormatString",
+                "customAreaChartTooltipStyleWithDifferentUnitSuffix",
+                "customAreaChartTooltipStyleWithColorfulHtmlLabels",
+                "customLineChartTooltipStyleWhenValueBeZeroDoNotShow",
+                "customBoxplotTooltipContent",
+                "customYAxisLabels",
+                "customYAxisLabels2",
+                "customStackedAndGroupedColumnChartTooltip",
+                "customDoubleXAxesChart",
+                "customArearangeChartTooltip",
+                "customLineChartOriginalPointPositionByConfiguringXAxisFormatterAndTooltipFormatter",
+                "customTooltipWhichDataSourceComeFromOutSideRatherThanSeries"
+            ), arrayOf( /*执行由 JavaScript 字符串映射转换成的 js function 函数*/
+                "evalJSFunction1",
+                "evalJSFunction2",
+                "evalJSFunction3"
+            ), arrayOf( /*Double Charts Linked Work---双表联动*/
+                "doubleChartsLinkedWork"
+            ), arrayOf( /*Scrollable Chart---可滚动图表*/
+                AAChartType.Column.value,
+                AAChartType.Bar.value,
+                AAChartType.Area.value,
+                AAChartType.Areaspline.value,
+                AAChartType.Area.value,
+                AAChartType.Line.value,
+                AAChartType.Line.value,
+                AAChartType.Spline.value
+            )
+        )
+    private val chartType: String? = null
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         setContentView(R.layout.activity_main)
+        setupExpandableListView()
+    }
 
-        val adapter = ArrayAdapter(
-            this@MainActivity, android.R.layout.simple_list_item_1, data
+    fun setupExpandableListView() {
+        val groupTitleArr = arrayOf(
+            "Basic Type Chart --- 基础类型图表",
+            "Special Type Chart --- 特殊类型图表",
+            "Mixed Chart --- 混合图形",
+            "Custom Style Chart---一些自定义风格样式图表",
+            "Draw Chart With AAOptions---通过Options绘图",
+            "Only Refresh data ---即时刷新图表数据",
+            "JS Function For AAOptionns ---通过带有 JS 函数的 Options 绘图",
+            "Evaluate JS String Function---执行js函数",
+            "Double Charts Linked Work---双表联动",
+            "Scrollable chart ---可滚动の图表"
         )
-        val listView = findViewById<View>(R.id.list) as ListView
-        listView.adapter = adapter
-
+        val listView =
+            findViewById(R.id.exlist_lol) as ExpandableListView
+        val myAdapter =
+            MyBaseExpandableListAdapter(groupTitleArr, chartTypeNameArr, this)
+        listView.setAdapter(myAdapter)
 
-        listView.onItemClickListener =
-            OnItemClickListener { adapter, view, position, id ->
-                println(position)
-                if (position <= 7) { /*基础类型图表*/
-                    goToCommonChartActivity(position)
-                } else if (position <= 20) { /*特殊类型图表*/
-                    goToSpecialChartActivity(position)
-                } else if (position <= 29) { /*Mixed Chart---混合图*/
-                    goToMixedChartActivity(position)
-                } else if (position <= 47) { /*自定义样式图表*/
-                    goToCustomStyleChartActivity(position)
-                } else if (position <= 65) { /*使用AAOptions绘制图表*/
-                    goToDrawChartWithAAOptionsActivity(position)
-                } else if (position <= 74) { /*即时刷新📈📊图表数据*/
-                    goToOnlyRefreshChartDataActivity(position)
-                } else if (position <= 87) { /*formatter js function*/
-                    goToCustomTooltipWithJSFunctionActivity(position)
-                } else if (position <= 89) { /*eval JS Function*/
-                    goToEvaluateJSStringFunctionActivity(position)
-                } else { /*Double Charts Linked Work*/
-                    goToDoubleChartsLinkedWorkActivity(position)
-                }
+        //为列表设置点击事件
+        listView.setOnChildClickListener { parent, v, groupPosition, childPosition, id ->
+            val chartType = chartTypeArr[groupPosition][childPosition] as String
+            when (groupPosition) {
+                0 -> goToCommonChartActivity(chartType, childPosition)
+                1 -> goToSpecialChartActivity(chartType)
+                2 -> goToMixedChartActivity(chartType)
+                3 -> goToCustomStyleChartActivity(chartType)
+                4 -> goToDrawChartWithAAOptionsActivity(chartType)
+                5 -> goToOnlyRefreshChartDataActivity(chartType)
+                6 -> goToCustomTooltipWithJSFunctionActivity(chartType)
+                7 -> goToEvaluateJSStringFunctionActivity(chartType)
+                8 -> goToDoubleChartsLinkedWorkActivity(chartType)
+                9 -> gotoScrollableChartActivity(chartType, childPosition)
             }
+            Toast.makeText(
+                this@MainActivity,
+                "你点击了:" + chartTypeNameArr[groupPosition][childPosition],
+                Toast.LENGTH_SHORT
+            ).show()
+            true
+        }
     }
 
-    private fun goToCommonChartActivity(position: Int) {
-        val intent = Intent(this, CommonChartActivity::class.java)
-        intent.putExtra("chartType", chartTypeArr[position])
+    fun goToCommonChartActivity(chartType: String?, position: Int) {
+        val intent =
+            Intent(this, CommonChartActivity::class.java)
+        intent.putExtra(kChartTypeKey, chartType)
         intent.putExtra("position", position)
-
         startActivity(intent)
     }
 
-    private fun goToSpecialChartActivity(position: Int) {
-        val intent = Intent(this, SpecialChartActivity::class.java)
-        intent.putExtra("chartType", chartTypeArr[position])
-
+    fun goToSpecialChartActivity(chartType: String?) {
+        val intent =
+            Intent(this, SpecialChartActivity::class.java)
+        intent.putExtra(kChartTypeKey, chartType)
         startActivity(intent)
     }
 
-    private fun goToCustomStyleChartActivity(position: Int) {
-        val intent = Intent(this, CustomStyleChartActivity::class.java)
-        intent.putExtra("chartType", chartTypeArr[position])
-
+    fun goToCustomStyleChartActivity(chartType: String?) {
+        val intent =
+            Intent(this, CustomStyleChartActivity::class.java)
+        intent.putExtra(kChartTypeKey, chartType)
         startActivity(intent)
     }
 
-    private fun goToMixedChartActivity(position: Int) {
-        val intent = Intent(this, MixedChartActivity::class.java)
-        intent.putExtra("chartType", chartTypeArr[position])
-
+    fun goToMixedChartActivity(chartType: String?) {
+        val intent =
+            Intent(this, MixedChartActivity::class.java)
+        intent.putExtra(kChartTypeKey, chartType)
         startActivity(intent)
     }
 
-    private fun goToDrawChartWithAAOptionsActivity(position: Int) {
-        val intent = Intent(this, DrawChartWithAAOptionsActivity::class.java)
-        intent.putExtra("chartType", chartTypeArr[position])
-
+    fun goToDrawChartWithAAOptionsActivity(chartType: String?) {
+        val intent = Intent(
+            this,
+            DrawChartWithAAOptionsActivity::class.java
+        )
+        intent.putExtra(kChartTypeKey, chartType)
         startActivity(intent)
     }
 
-    private fun goToOnlyRefreshChartDataActivity(position: Int) {
-        val intent = Intent(this, OnlyRefreshChartDataActivity::class.java)
-        intent.putExtra("chartType", chartTypeArr[position])
+    fun goToOnlyRefreshChartDataActivity(chartType: String?) {
+        val intent = Intent(
+            this,
+            OnlyRefreshChartDataActivity::class.java
+        )
+        intent.putExtra(kChartTypeKey, chartType)
         startActivity(intent)
     }
 
-    private fun goToHideOrShowChartSeriesActivity(position: Int) {
-        val intent = Intent(this, HideOrShowChartSeriesActivity::class.java)
-        intent.putExtra("chartType", chartTypeArr[position])
-
+    fun goToCustomTooltipWithJSFunctionActivity(chartType: String?) {
+        val intent = Intent(
+            this,
+            JSFormatterFunctionActivity::class.java
+        )
+        intent.putExtra(kChartTypeKey, chartType)
         startActivity(intent)
     }
 
-    private fun goToCustomTooltipWithJSFunctionActivity(position: Int) {
-        val intent = Intent(this, JSFormatterFunctionActivity::class.java)
-        intent.putExtra("chartType", chartTypeArr[position])
-
+    fun goToEvaluateJSStringFunctionActivity(chartType: String?) {
+        val intent = Intent(
+            this,
+            EvaluateJSStringFunctionActivity::class.java
+        )
+        intent.putExtra(kChartTypeKey, chartType)
         startActivity(intent)
     }
 
-
-    private fun goToEvaluateJSStringFunctionActivity(position: Int) {
-        val intent = Intent(this, EvaluateJSStringFunctionActivity::class.java)
-        intent.putExtra("chartType", chartTypeArr[position])
-
+    fun goToHideOrShowChartSeriesActivity(chartType: String?) {
+        val intent = Intent(
+            this,
+            HideOrShowChartSeriesActivity::class.java
+        )
+        intent.putExtra(kChartTypeKey, chartType)
         startActivity(intent)
     }
 
-    private fun goToDoubleChartsLinkedWorkActivity(position: Int) {
+    fun goToDoubleChartsLinkedWorkActivity(chartType: String?) {
         val intent = Intent(
-            this, DoubleChartsLinkedWorkActivity::class.java
+            this,
+            DoubleChartsLinkedWorkActivity::class.java
         )
-        intent.putExtra("chartType", chartTypeArr[position])
+        intent.putExtra(kChartTypeKey, chartType)
         startActivity(intent)
     }
+
+    fun gotoScrollableChartActivity(chartType: String?, position: Int) {
+//        val intent =
+//            Intent(this, ScrollableChartActivity::class.java)
+//        intent.putExtra(kChartTypeKey, chartType)
+//        intent.putExtra("position", position)
+//        startActivity(intent)
+    }
+
+    companion object {
+        private const val kChartTypeKey = "chartType"
+    }
 }

+ 116 - 0
sample/src/main/java/com/github/aachartmodel/aainfographics/demo/basiccontent/MyBaseExpandableListAdapter.kt

@@ -0,0 +1,116 @@
+package com.github.aachartmodel.aainfographics.demo.basiccontent
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.BaseExpandableListAdapter
+import android.widget.ImageView
+import android.widget.TextView
+import com.github.aachartmodel.aainfographics.demo.R
+
+class MyBaseExpandableListAdapter(
+    private val gData: Array<String>,
+    private val iData: Array<Array<String>>,
+    private val mContext: Context
+) :
+    BaseExpandableListAdapter() {
+    override fun getGroupCount(): Int {
+        return gData.size
+    }
+
+    override fun getChildrenCount(groupPosition: Int): Int {
+        return iData[groupPosition].count()
+    }
+
+    override fun getGroup(groupPosition: Int): String {
+        return gData[groupPosition]
+    }
+
+    override fun getChild(groupPosition: Int, childPosition: Int): String {
+        return iData[groupPosition][childPosition]
+    }
+
+    override fun getGroupId(groupPosition: Int): Long {
+        return groupPosition.toLong()
+    }
+
+    override fun getChildId(groupPosition: Int, childPosition: Int): Long {
+        return childPosition.toLong()
+    }
+
+    override fun hasStableIds(): Boolean {
+        return false
+    }
+
+    //取得用于显示给定分组的视图. 这个方法仅返回分组的视图对象
+    override fun getGroupView(
+        groupPosition: Int,
+        isExpanded: Boolean,
+        convertView: View?,
+        parent: ViewGroup
+    ): View? {
+        var convertView = convertView
+        val groupHolder: ViewHolderGroup
+        if (convertView == null) {
+            convertView = LayoutInflater.from(mContext).inflate(
+                R.layout.item_exlist_group, parent, false
+            )
+            groupHolder =
+                ViewHolderGroup()
+            groupHolder.tv_group_name =
+                convertView.findViewById<View>(R.id.tv_group_name) as TextView
+            convertView.tag = groupHolder
+        } else {
+            groupHolder =
+                convertView.tag as ViewHolderGroup
+        }
+        groupHolder.tv_group_name!!.text = gData[groupPosition]
+        return convertView
+    }
+
+    //取得显示给定分组给定子位置的数据用的视图
+    override fun getChildView(
+        groupPosition: Int,
+        childPosition: Int,
+        isLastChild: Boolean,
+        convertView: View?,
+        parent: ViewGroup
+    ): View? {
+        var convertView = convertView
+        val itemHolder: ViewHolderItem
+        if (convertView == null) {
+            convertView = LayoutInflater.from(mContext).inflate(
+                R.layout.item_exlist_item, parent, false
+            )
+            itemHolder =
+                ViewHolderItem()
+            itemHolder.img_icon =
+                convertView.findViewById<View>(R.id.img_icon) as ImageView
+            itemHolder.tv_name =
+                convertView.findViewById<View>(R.id.tv_name) as TextView
+            convertView.tag = itemHolder
+        } else {
+            itemHolder =
+                convertView.tag as ViewHolderItem
+        }
+        //        itemHolder.img_icon.setImageResource(iData.get(groupPosition).get(childPosition).get);
+        itemHolder.tv_name!!.text = iData[groupPosition][childPosition]
+        return convertView
+    }
+
+    //设置子列表是否可选中
+    override fun isChildSelectable(groupPosition: Int, childPosition: Int): Boolean {
+        return true
+    }
+
+    private class ViewHolderGroup {
+        var tv_group_name: TextView? = null
+    }
+
+    private class ViewHolderItem {
+        var img_icon: ImageView? = null
+        var tv_name: TextView? = null
+    }
+
+}

+ 5 - 6
sample/src/main/res/layout/activity_main.xml

@@ -5,11 +5,10 @@
     android:layout_height="match_parent"
     tools:context=".basiccontent.MainActivity">
 
-    <ListView
-        android:id="@+id/list"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent">
-
-    </ListView>
+    <ExpandableListView
+            android:id="@+id/exlist_lol"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:childDivider="#E02D2F"/>
 
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 18 - 0
sample/src/main/res/layout/item_exlist_group.xml

@@ -0,0 +1,18 @@
+<?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="5dp">
+
+    <TextView
+        android:id="@+id/tv_group_name"
+        android:layout_width="match_parent"
+        android:layout_height="56dp"
+        android:gravity="center_vertical"
+        android:paddingLeft="30dp"
+        android:text="AP"
+        android:textStyle="bold"
+        android:textSize="20sp" />
+
+</LinearLayout>

+ 26 - 0
sample/src/main/res/layout/item_exlist_item.xml

@@ -0,0 +1,26 @@
+<?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="5dp"
+    android:background="#6BBA79">
+
+    <ImageView
+        android:id="@+id/img_icon"
+        android:layout_width="48dp"
+        android:layout_height="48dp"
+        android:src="@android:color/holo_blue_bright"
+        android:focusable="false"/>
+
+    <TextView
+        android:id="@+id/tv_name"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="15dp"
+        android:layout_marginTop="15dp"
+        android:focusable="false"
+        android:text="提莫"
+        android:textSize="18sp" />
+
+</LinearLayout>