밝기 제어 대화 상자를 만들고 있습니다. 그러나 나는 데 문제는 내가 다음 텍스트 뷰를 넣을 때이 오류가 발생 SeekBar를한다는 것입니다 : .XML의 위치는 다음 텍스트 뷰를 검색 막대를 다음과 때 작동하는 것 같다 몇 가지 이유를 들어android.widget.SeekBar을 android.widget.TextView로 형 변환 할 수 없습니다.
android.widget.SeekBar cannot be cast to android.widget.TextView
.
LayoutInflater li_brightness = (LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE);
View v_brightness = li_brightness.inflate(R.layout.options_dialog_brightness, (ViewGroup)findViewById(R.id.ll_brightness_layout));
bright_textView = (TextView)v_brightness.findViewById(R.id.brightness_text);
brightBar = (SeekBar)v_brightness.findViewById(R.id.seekbar_brightness);
confirm_brightness = (Button)v_brightness.findViewById(R.id.button_brightness);
cResolver = getContentResolver();
window = getWindow();
brightBar.setMax(100);
brightBar.setProgress(50);
brightBar.setKeyProgressIncrement(1);
bright_textView.setText("50".toString());
brightBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// TODO Auto-generated method stub
float BackLightValue = (float)progress/100;
if(BackLightValue <= 0){
bright_textView.setText(String.valueOf(BackLightValue));
}
WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
layoutParams.screenBrightness = BackLightValue;
getWindow().setAttributes(layoutParams);
}
});
logcat과 XML을 추가하십시오.하지만 확실하지는 않습니다. XML 레이아웃 파일의 ID로 인해 문제가 발생합니다. Seekbar에 textview의 ID를 입력하십시오. –