2016-06-30 3 views
1

CustomMarkerViewクラスを作成しようとしています。しかし、のrefreshContentをオーバーライドすると、メソッドがそのスーパークラスからオーバーライドされず、"highlight"パラメータが使用されないことが示されますAndroid MPAndroidCharts

CustomMarkerView.javaサンプルコード

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 entries, Highlight highlight) { 
     tvContent.setText("" + entries.getVal()); 
     // set the entry-value as the display text 
    } 


    @Override 
    public int getXOffset() { 
     // this will center the marker-view horizontally 
     return -(getWidth()/2); 
    } 

    @Override 
    public int getYOffset() { 
     // this will cause the marker-view to be above the selected value 
     return -getHeight(); 
    } 
} 

私が直接、私は何をしないのです

https://github.com/PhilJay/MPAndroidChart/wiki/MarkerView

からコードを対処してきましたか?

答えて

1

Hei、ちょうどあなたのコードをチェックしました。あなたは

compile 'com.github.PhilJay:MPAndroidChart:v2.2.5' 

にごMPAndroidChartのバージョンを更新して(あなたのコードで行われた変更)以下のコードを使用している場合や、パブリッククラスCustomMarkerViewは{

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 entries, Highlight highlight) { 
    tvContent.setText(" " + entries.getVal()); 
    // set the entry-value as the display text 
} 

@Override 
public int getXOffset(float xpos) { 
    return -(getWidth()/2); 
} 

@Override 
public int getYOffset(float ypos) { 
    return -getHeight(); 
} 
MarkerViewを拡張 `...私の側に正常に動作するようです

} `

+0

ありがとうございました。それは今働く。実際には、refreshContentメソッドの引数が異なることを求めていました:@Override public void refreshContent(Entry e、int dataSetIndex){ tvContent.setText( "" + e.getVal()); } – Scarlet

+0

私はそれのためにupvoteを得ることができますか? –

関連する問題