如何删除或隐藏 MPAndroidChart 中的 MarkerView?

Gra*_*ein 8 android bar-chart mpandroidchart

我用MPAndroidChart做了一个条形图。我做了一个自定义标记视图类来查看条形图的值。
几秒钟后我会删除或隐藏视图。它应该起到祝酒的作用。但我做不到。
首先这是一个问题,因为在我第一次触摸图表后,它变得可见,并且只有当我找到正确的点击条件时它才会消失。

有人知道如何解决这个问题吗?

在我的代码中我有:

mChart.invalidate();
mv = new CustomMarkerView(getContext(), R.layout.alert_chart, position, jsonResponse);
mChart.setMarker(mv);
Run Code Online (Sandbox Code Playgroud)

我的 CustomMarkerView 是

public class CustomMarkerViewextends MarkerView {

public TextView correct;
public TextView wrong ;
public int position;
public JSONArray jsonArray;

public CustomMarkerView(Context context, int layoutResource, int pos, JSONArray json) {
    super(context, layoutResource);

    correct = (TextView) findViewById(R.id.correct);
    wrong = (TextView) findViewById(R.id.wrong);

    position = pos;
    jsonArray = json;

}

@Override
public void refreshContent(Entry e, Highlight highlight) {
    switch (position){
        case 1:
            try {
                correct.setText(getContext().getString(R.string.correct_alert) + "   " + jsonArray.getJSONObject((int)(e.getX())).getString("TP"));
                wrong.setText(getContext().getString(R.string.wrong_alert) + "   " + jsonArray.getJSONObject((int)(e.getX())).getString("FP"));        
            } catch (JSONException e1) {
                e1.printStackTrace();
            } catch (ParseException e1) {
                e1.printStackTrace();
            }

            break;
        case 2:
            try {
                correct.setText(getContext().getString(R.string.tpr_alert) + "   " + Math.round(Double.parseDouble(jsonArray.getJSONObject((int)(e.getX())).getString("TPR"))*100.0)/100.0);
                wrong.setText(getContext().getString(R.string.msr_alert) + "   " + Math.round(Double.parseDouble(jsonArray.getJSONObject((int)(e.getX())).getString("MSR"))*100.0)/100.0);
            } catch (JSONException e1) {
                e1.printStackTrace();
            } catch (ParseException e1) {
                e1.printStackTrace();
            }

            break;
        case 3:
            try {
                correct.setText(getContext().getString(R.string.nmean_alert) + "   " +Math.round(Double.parseDouble(jsonArray.getJSONObject((int)(e.getX())).getString("n_mean"))*100.0)/100.0);
                wrong.setText(getContext().getString(R.string.nmax_alert) + "   " +Math.round(Double.parseDouble(jsonArray.getJSONObject((int)(e.getX())).getString("n_max"))*100.0)/100.0);
            } catch (JSONException e1) {
                e1.printStackTrace();
            } catch (ParseException e1) {
                e1.printStackTrace();
            }

            break;
    }

    // this will perform necessary layouting
    super.refreshContent(e, highlight);

}

private MPPointF mOffset;

@Override
public MPPointF getOffset() {

    if(mOffset == null) {
        // center the marker horizontally and vertically
        mOffset = new MPPointF(-(getWidth()/2), -getHeight());
    }

    return mOffset;
}
Run Code Online (Sandbox Code Playgroud)

}

Vad*_*dim 8

我知道,有点晚了,但是:

mChart.highlightValue(null);
Run Code Online (Sandbox Code Playgroud)

为我工作