결과화면

 

 package com.example.demo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.*;

public class ProgressBarDemo1 extends Activity {
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  //윈도우에 진행 상태바 설정.
  requestWindowFeature(Window.FEATURE_PROGRESS);
  setProgressBarVisibility(true); //위에 requestWindowFeature 를 true로 지정한거임..
  
  setContentView(R.layout.progress_1);
  
  final ProgressBar progressHorizontal =
    (ProgressBar)findViewById(R.id.progress_horizontal);
  
  setProgress(progressHorizontal.getProgress() * 100);
  setSecondaryProgress(progressHorizontal.getSecondaryProgress() * 100);
  
  Button button = (Button)findViewById(R.id.increase);
  button.setOnClickListener(new Button.OnClickListener(){
   public void onClick(View v){
    progressHorizontal.incrementProgressBy(1);
    //Title progress is in range 0..10000
    setProgress(100 * progressHorizontal.getProgress());
   }
  });
  
  button = (Button)findViewById(R.id.decrease);
  button.setOnClickListener(new Button.OnClickListener(){
   public void onClick(View v){
    progressHorizontal.incrementProgressBy(-1);
    //Title progress is in range 0..10000
    setProgress(100 * progressHorizontal.getProgress());
   }
  });
  
  button = (Button)findViewById(R.id.increase_secondary);
  button.setOnClickListener(new Button.OnClickListener(){
   public void onClick(View v){
    progressHorizontal.incrementSecondaryProgressBy(1);
    //Title progress is in range 0..10000
    setProgress(100 * progressHorizontal.getProgress());
   }
  });
  
  button = (Button)findViewById(R.id.decrease_secondary);
  button.setOnClickListener(new Button.OnClickListener(){
   public void onClick(View v){
    progressHorizontal.incrementSecondaryProgressBy(-1);
    //Title progress is in range 0..10000
    setProgress(100 * progressHorizontal.getProgress());
   }
  });
 }
}

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ProgressBar android:id="@+id/progress_horizontal"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="200dip"
        android:layout_height="wrap_content"
        android:max="100"
        android:progress="50"
        android:secondaryProgress="75" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/progressbar_1_default_progress" />       

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <Button android:id="@+id/decrease"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/progressbar_1_minus" />

        <Button android:id="@+id/increase"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/progressbar_1_plus" />

    </LinearLayout>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/progressbar_1_secondary_progress" />       

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <Button android:id="@+id/decrease_secondary"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/progressbar_1_minus" />

        <Button android:id="@+id/increase_secondary"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/progressbar_1_plus" />

    </LinearLayout>

</LinearLayout>

//String.xml에 다음 코드 추가~~

 

 <string name="progressbar_1_plus">+</string>
    <string name="progressbar_1_minus">-</string>
    <string name="progressbar_1_default_progress">Default progress:</string>
    <string name="progressbar_1_secondary_progress">Secondary progress:</string>

 

'2020년도 이전 > [WebSig] Android' 카테고리의 다른 글

ProgressBar Demo3  (0) 2013.08.13
ProgressBar Demo2 -> 원형 프로그레스 바  (0) 2013.08.13
Image Demo  (0) 2013.08.13
AutoText Demo 자동완성 텍스트뷰  (0) 2013.08.13
Spinner Demo  (0) 2013.08.13

+ Recent posts