我已经创建了搜索栏,我想更新textview中的搜索栏值。我做了以下事情。
布局文件的一部分是
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.15" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="49dp"
android:background="@drawable/circle"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.90" >
<TextView
android:id="@+id/seekvalue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text=" " />
</RelativeLayout>
</LinearLayout>
<SeekBar
android:id="@+id/showvalue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/linearLayout1" />
Java代码是
text=(TextView)findViewById(R.id.seekvalue);
// slide_me.setRightBehindContentView(R.layout.right_menu);
slider=(SeekBar)findViewById(R.id.showvalue);
slider.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
// int progressChanged = 0;
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser){
// progressChanged = progress;
text.setText(progress);
}
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
我有以下运行时错误
09-29 08:08:51.732: E/AndroidRuntime(428): FATAL EXCEPTION: main
09-29 08:08:51.732: E/AndroidRuntime(428): android.content.res.Resources$NotFoundException: String resource ID #0x1
09-29 08:08:51.732: E/AndroidRuntime(428): at android.content.res.Resources.getText(Resources.java:201)
09-29 08:08:51.732: E/AndroidRuntime(428): at android.widget.TextView.setText(TextView.java:2817)
09-29 08:08:51.732: E/AndroidRuntime(428): at com.android.waitress.Calculator$1.onProgressChanged(Calculator.java:39)
09-29 08:08:51.732: E/AndroidRuntime(428): at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
09-29 08:08:51.732: E/AndroidRuntime(428): at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:506)
所以请帮我...谢谢
您progress
是Integer
,因此TextView
将其理解为“资源ID”。解决此问题的方法:
text.setText("" +progress);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句