在标记布局上的MPAndroidChart中添加TouchListener

时间:2017-11-15 09:56:13

标签: android android-layout onclicklistener ontouchlistener mpandroidchart

当用户触摸标记时,想要在标记布局上的MPAndroidChart中添加TouchListener(tvContent)我想显示另一个活动。**

在标记上设置值,但我想实现Touch侦听器以显示另一个活动。**

git revert 29f4a2 #your commit ID

主要活动

public class XYMarkerView extends MarkerView {
private TextView tvContent;
public RelativeLayout main;
private IAxisValueFormatter xAxisValueFormatter;
public Context mcontext;
private DecimalFormat format;

public XYMarkerView(Context context, IAxisValueFormatter xAxisValueFormatter) {
    super(context, R.layout.custom_marker_view);
    mcontext = context;
    this.xAxisValueFormatter = xAxisValueFormatter;
    tvContent = (TextView) findViewById(R.id.tvContent);
    main = (RelativeLayout) findViewById(R.id.mainmarker);

    format = new DecimalFormat("###.0");
    main.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {

        }
    });
    main.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            return false;
        }
    });
}


// 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(" " + xAxisValueFormatter.getFormattedValue(e.getX(), null) + ", : " + format.format(e.getY()));
    main.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            Toast.makeText(getContext(), "ohhh!", Toast.LENGTH_SHORT);

        }
    });
    main.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            return false;
        }
    });
    super.refreshContent(e, highlight);
}

0 个答案:

没有答案