Как удалить или скрыть MarkerView в MPAndroidChart?Android

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Как удалить или скрыть MarkerView в MPAndroidChart?

Сообщение Anonymous »

Я создал гистограмму с помощью MPAndroidChart. Я создал собственный класс представления маркеров для просмотра значений панели.

Я удалял или скрывал представление через несколько секунд. Это должно сработать как тост. Но я не могу этого сделать.

Это проблема прежде всего потому, что после того, как я впервые прикоснулся к графику, он становится видимым и исчезает только в том случае, если я нахожу правильное состояние касания.

Кто-нибудь знает, как решить эту проблему?

В моем коде:

Код: Выделить всё

mChart.invalidate();
mv = new CustomMarkerView(getContext(), R.layout.alert_chart, position, jsonResponse);
mChart.setMarker(mv);
И мой 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;
}


Подробнее здесь: https://stackoverflow.com/questions/437 ... droidchart
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»