Я удалял или скрывал представление через несколько секунд. Это должно сработать как тост. Но я не могу этого сделать.
Это проблема прежде всего потому, что после того, как я впервые прикоснулся к графику, он становится видимым и исчезает только в том случае, если я нахожу правильное состояние касания.
Кто-нибудь знает, как решить эту проблему?
В моем коде:
Код: Выделить всё
mChart.invalidate();
mv = new CustomMarkerView(getContext(), R.layout.alert_chart, position, jsonResponse);
mChart.setMarker(mv);
Код: Выделить всё
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
Мобильная версия