티스토리 뷰
package whdghks913.tistory.exampleseekbar;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.WindowManager;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
public class MainActivity extends Activity {
SeekBar seekbar;
TextView status;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
seekbar = (SeekBar) findViewById(R.id.seekbar);
status = (TextView) findViewById(R.id.status);
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// TODO Auto-generated method stub
if(progress<10){
progress=10;
seekbar.setProgress(progress);
}
status.setText("밝기 수준 : " + progress);
WindowManager.LayoutParams params = getWindow().getAttributes();
params.screenBrightness = (float) progress / 100;
getWindow().setAttributes(params);
}
});
}
class SeekBar_Listener implements OnSeekBarChangeListener {
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if(progress<10){
progress=10;
seekbar.setProgress(progress);
}
status.setText("밝기 수준 : " + progress);
WindowManager.LayoutParams params = getWindow().getAttributes();
params.screenBrightness = (float) progress / 100;
getWindow().setAttributes(params);
}
public void onStartTrackingTouch(SeekBar seekBar) {
}
public void onStopTrackingTouch(SeekBar seekBar) {
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
'Computer > Android' 카테고리의 다른 글
AIDL (0) | 2014.02.25 |
---|---|
언어별 values 값 설정 (0) | 2014.02.24 |
[Android(안드로이드) 앱 개발 기초] Fragment 기초 (0) | 2014.02.19 |
안드로이드 기본 API 활용 노하우 (0) | 2014.01.23 |
Android BroadCast Receiver (0) | 2014.01.22 |