Androidのように複数のシークバーを実装しました
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sb1=(SeekBar) findViewById(R.id.seekBar1);
sb2=(SeekBar) findViewById(R.id.seekBar2);
sb3=(SeekBar) findViewById(R.id.seekBar3);
tv1=(TextView) findViewById(R.id.textView1);
tv2=(TextView) findViewById(R.id.textView2);
tv3=(TextView) findViewById(R.id.textView3);
sb1.setOnSeekBarChangeListener(this);
sb2.setOnSeekBarChangeListener(this);
sb3.setOnSeekBarChangeListener(this);
}
@Override
public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2)
{
switch (arg0.getId())
{
case R.id.seekBar1:
tv1.setText(arg1);
break;
case R.id.seekBar2:
tv2.setText(arg1);
break;
case R.id.seekBar3:
tv3.setText(arg1);
break;
}
}
@Override
public void onStartTrackingTouch(SeekBar arg0)
{
// TODO Auto-generated method stub
}
@Override
public void onStopTrackingTouch(SeekBar arg0)
{
// TODO Auto-generated method stub
}
このアプリを実行すると、次のエラーが発生します。
致命的な例外: メイン
07-18 15:41:13.200: E/AndroidRuntime(596): android.content.res.Resources$NotFoundException:String resource ID #0x1
07-18 15:41:13.200: E/AndroidRuntime(596): at android.content.res.Resources.getText(Resources.java:201)
07-18 15:41:13.200: E/AndroidRuntime(596): at android.widget.TextView.setText(TextView.java:2817)
07-18 15:41:13.200: E/AndroidRuntime(596): at com.example.allocationseekbar.MainActivity.onProgressChanged(MainActivity.java:42)
07-18 15:41:13.200: E/AndroidRuntime(596): at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
07-18 15:41:13.200: E/AndroidRuntime(596): at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:506)
07-18 15:41:13.200: E/AndroidRuntime(596): at android.widget.ProgressBar.refreshProgress(ProgressBar.java:515)
07-18 15:41:13.200: E/AndroidRuntime(596): at android.widget.ProgressBar.setProgress(ProgressBar.java:564)
07-18 15:41:13.200: E/AndroidRuntime(596): at android.widget.AbsSeekBar.trackTouchEvent(AbsSeekBar.java:337)
07-18 15:41:13.200: E/AndroidRuntime(596): at android.widget.AbsSeekBar.onTouchEvent(AbsSeekBar.java:292)
07-18 15:41:13.200: E/AndroidRuntime(596): at android.view.View.dispatchTouchEvent(View.java:3766)
07-18 15:41:13.200: E/AndroidRuntime(596): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-18 15:41:13.200: E/AndroidRuntime(596): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-18 15:41:13.200: E/AndroidRuntime(596): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-18 15:41:13.200: E/AndroidRuntime(596): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-18 15:41:13.200: E/AndroidRuntime(596): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1671)
07-18 15:41:13.200: E/AndroidRuntime(596): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
07-18 15:41:13.200: E/AndroidRuntime(596): at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
07-18 15:41:13.200: E/AndroidRuntime(596): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1655)
07-18 15:41:13.200: E/AndroidRuntime(596): at android.view.ViewRoot.handleMessage(ViewRoot.java:1785)
07-18 15:41:13.200: E/AndroidRuntime(596): at android.os.Handler.dispatchMessage(Handler.java:99)
07-18 15:41:13.200: E/AndroidRuntime(596): at android.os.Looper.loop(Looper.java:123)
07-18 15:41:13.200: E/AndroidRuntime(596): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-18 15:41:13.200: E/AndroidRuntime(596): at java.lang.reflect.Method.invokeNative(Native Method)
07-18 15:41:13.200: E/AndroidRuntime(596): at java.lang.reflect.Method.invoke(Method.java:521)
07-18 15:41:13.200: E/AndroidRuntime(596): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-18 15:41:13.200: E/AndroidRuntime(596): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-18 15:41:13.200: E/AndroidRuntime(596): at dalvik.system.NativeStart.main(Native Method)
なぜこれが起こっているのかわかりません。私を助けてください。よろしくお願いします