0
私はアプリを実行すると、 "ZygoteInit $ methodandargscaller.run()source not found"エラーといくつかの他の "source not found"エラーでクラッシュします。それはまたnullpointerexceptionについて何かを言います それは1つのラインをクラッシュします:tap [0] =(int)(System.nanoTime()/ 1000000 - tapstart);
package com.metronome;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
public class MetronomeActivity extends Activity {
public int bpm = 150;
private long tapstart = 0;
private int tap[];
private int cnt = 0;
private int gnstap = 0;
private int sum;
FrameLayout mainFrame;
SeekBar Bar;
TextView bpmText;
ToggleButton toggle;
MediaPlayer mp;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mainFrame = (FrameLayout) findViewById(R.id.FrameLayout);
Bar = (SeekBar) findViewById(R.id.seekBar1);
bpmText = (TextView) findViewById(R.id.textView1);
toggle = (ToggleButton) findViewById(R.id.toggleButton1);
bpmText.setText(bpm + " BPM");
// listeners
mainFrame.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (tapstart != 0) {
tap[0] = (int) (System.nanoTime()/1000000 - tapstart);
tapstart = (System.nanoTime()/1000000);
if (cnt < 9) {
cnt++;
} else {
cnt = 0;
}
sum = 0;
for(int i=0; i < tap.length ; i++)
sum = sum + tap[i];
gnstap = sum/tap.length;
bpm = 60000/gnstap;
bpmText.setText(bpm + " BPM");
}
else {
tapstart = (System.nanoTime()/1000000);
}
}
});
}
}