Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
209 views
in Technique[技术] by (71.8m points)

mpchartandroid - MpCharts android is able to show Markerview background but not able to update text on the same

Here is the markerview file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/white">

<TextView
    android:id="@+id/tvContent"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/fit"
    android:ellipsize="end"
    android:gravity="center"
    android:minWidth="@dimen/dp_40"
    android:singleLine="true"
    android:tag="custommarker"
    android:text="10"
    android:textColor="@color/black"
    android:textSize="15sp" />
</RelativeLayout>

Here is the custommarkerview classs

public class CustomMarkerView extends MarkerView {

private TextView tvContent;

public CustomMarkerView(Context context, int layoutResource) {
    super(context, layoutResource);
    // this markerview only displays a textview
    tvContent = (TextView) findViewById(R.id.tvContent);
}

// callbacks everytime the MarkerView is redrawn, can be used to update the
// content (user-interface)
@Override
public void refreshContent(Entry e, Highlight highlight) {
    tvContent.setText("" + e.getY()); // set the entry-value as the display text
    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;
}
}
question from:https://stackoverflow.com/questions/65916954/mpcharts-android-is-able-to-show-markerview-background-but-not-able-to-update-te

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...