小编Tus*_*uss的帖子

如何用不同的子串替换多个子串?

我从文本文件中获得了这一和弦.例如,

String chordLine = "C     G   Am  C";
String transposedChordLine;
Run Code Online (Sandbox Code Playgroud)

接下来,我需要使用两个参数,即转置的和弦和整数增量,使用下面的类将其chordLine转换为新transposedChordLineString.例如,transpose("C", 2)将返回D.

 public class Transposer{
    private int inc;
    private static ArrayList<String> keysSharp;
    private static ArrayList<String> keysFlat;

    Transposer(){
        keysSharp = new ArrayList<String>(Arrays.asList("C", "C#", "D", "D#","E", "F","F#", "G","G#", "A","A#", "B"));
        keysFlat = new ArrayList<String>(Arrays.asList("C", "Db", "D", "Eb","E", "F","Gb", "G","Ab", "A","Bb", "B"));
    }

    public String transpose(String chord,int inc){

        this.inc = inc;

        String newChord;

        if(chord.contains("/")){
            String[] split = chord.split("/");
            newChord = transposeKey(split[0]) + "/" …
Run Code Online (Sandbox Code Playgroud)

java string replace

5
推荐指数
1
解决办法
127
查看次数

GraphView,如何显示x轴标签?

我正在尝试使用GraphView库绘制图形.我的问题是,x轴没有显示,但y轴可以.此外,x轴标签上的值也没有显示出来.

这是我的xml文件:

    <com.jjoe64.graphview.GraphView
        android:id="@+id/graph"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentTop="true"
        android:background="#FAFA82" />
Run Code Online (Sandbox Code Playgroud)

和java代码:

double graph1LastXValue = 5d;
GraphView graph = (GraphView) findViewById(R.id.graph);
graph.getGridLabelRenderer().setVerticalAxisTitle("Match Value");
graph.getGridLabelRenderer().setHorizontalAxisTitle("Time/s");
Series2 = new LineGraphSeries<DataPoint>();
mSeries1.setColor(Color.RED);
mSeries1.setThickness(2);
graph.addSeries(mSeries2);
graph.getViewport().setXAxisBoundsManual(true);
graph.getViewport().setMinX(0);
graph.getViewport().setMaxX(100);
graph.getGridLabelRenderer().setGridStyle(GridStyle.BOTH);
plotter(matchValMean);

protected void plotter(Double matchVal) {
matchValue = matchVal;
// TODO Auto-generated method stub
mTimer1 = new Runnable() {
    @Override
     public void run() {
            graph1LastXValue += 1d;
            mSeries1.appendData(new DataPoint(graph1LastXValue, matchValue), true, 100);
            mHandler.postDelayed(this, 1000);
        }
    };
    mHandler.postDelayed(mTimer1, 1000);
}
Run Code Online (Sandbox Code Playgroud)

我没有显示所有代码,因为它很长.提前致谢 :)

android android-graphview

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

android-graphview ×1

java ×1

replace ×1

string ×1