반응형
안드로이드 프로그레스바 예제 소스입니다.
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>
실행화면
반응형
'Language > Android' 카테고리의 다른 글
| 안드로이드(Android) 메뉴 옵션 예제 (0) | 2013.02.26 |
|---|---|
| 안드로이드 체크박스(Android checkbox) 예제 (0) | 2013.02.26 |
| 안드로이드(Android) SDK 설치 방법 (8) | 2013.02.14 |
| 안드로이드 시크바(Android SeekBar) (2) | 2013.02.07 |
| 안드로이드 스피너(Android Spinner),콤보박스 (4) | 2013.02.06 |
| 안드로이드 웹뷰(Android WebView) 예제 (11) | 2013.02.06 |
| 안드로이드 타이머(Android Timer) (0) | 2013.01.29 |
| 안드로이드 다이얼로그(Android Dialog-확인,중립,취소 버튼) (0) | 2013.01.29 |
| 안드로이드 비밀번호(password) 가리기 및 보이기 (0) | 2013.01.28 |
| 안드로이드 토스트(Android Toast) 예제 (0) | 2013.01.28 |