小编Aks*_*nde的帖子

获取活动中选择的图表

我正在使用最新版本的mpandroidchart库.我在单项活动上有2个条形图.chart1和chart2是XML中的id(我不想使用条形图列表视图).chart1 cosnist计数值和图表2包含美元价值.我已经获得了价值.但我想知道这是一个美元价值还是价值.所以我可以根据选中的图表显示吐司.

这是我的示例代码.

 public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {

    View view;
    TextView text;

    switch (e.getXIndex()) {
        case 0:

            if (toast != null)
                toast.cancel();

            toast = Toast.makeText(getActivity(), "All Other Year Defectors: " +e.getVal(), Toast.LENGTH_SHORT);

            view = toast.getView();
            view.setBackgroundResource(R.color.all_odr_yr);
            toast.setGravity(Gravity.TOP, 0, 950);
            toast.show();
            break;


        case 1:
            if (toast != null)
                toast.cancel();

            toast = Toast.makeText(getActivity(), "Last Year Defectors: " + e.getVal(), Toast.LENGTH_SHORT);

            view = toast.getView();
            view.setBackgroundResource(R.color.lst_yr_df);
            toast.setGravity(Gravity.TOP, 0, 950);
            toast.show();
            break;
Run Code Online (Sandbox Code Playgroud)

android mpandroidchart

3
推荐指数
1
解决办法
1493
查看次数

标签 统计

android ×1

mpandroidchart ×1