안드로이드 프로그레스바 예제 소스입니다.


MainActivity

package com.example.ggari_progressbar;
 
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
 
public class MainActivity extends Activity {
 
    ProgressBar progressbar;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        progressbar = (ProgressBar) findViewById(R.id.progressbar);
 
        findViewById(R.id.btnStart).setOnClickListener(OnClick);
        findViewById(R.id.btnStop).setOnClickListener(OnClick);
    }
 
    Button.OnClickListener OnClick = new View.OnClickListener() {
        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.btnStart:
                progressbar.setVisibility(View.VISIBLE);
                break;
            case R.id.btnStop:
                progressbar.setVisibility(View.INVISIBLE);
                break;
            }
        }
    };
 
}



activity_main.xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">
    <ProgressBar android:id="@+id/ProgressBar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="invisible">
 
    <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
        <Button android:id="@+id/btnStart" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="시작">
        </Button><Button android:id="@+id/btnStop" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="정지">
    <LinearLayout>
</LinearLayout>
</Button></LinearLayout></ProgressBar></LinearLayout>



실행화면

Posted by 준콩ol 준콩ol

댓글을 달아 주세요