2

검색 막대를 만들었습니다 & textview에서 검색 막대 값을 업데이트하고 싶습니다. 나는 다음 일을했다.seekbar에서 런타임 오류가 발생했습니다

레이아웃 파일의 일부가

,

<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" /> 

자바 코드는, 내가 그렇게 저를 도와주세요 런타임 오류

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) 

다음 가지고

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) { 

       } 
      });  

... 감사합니다.

답변

2

progressInteger이므로 TextView은 '리소스 ID'로 인식합니다. 이 문제를 해결하려면

text.setText("" +progress); 
관련 문제