[안드로이드]프로그레스바,ProgressBar
2013. 1. 30. 13:01ㆍMobile/Android
반응형
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;
}
}
};
}
<?xml version="1.0" encoding="utf-8"?>
<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
android:id="@+id/btnStop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="정지" />
<LinearLayout>
</LINEARLAYOUT>
반응형
'Mobile > Android' 카테고리의 다른 글
| [안드로이드,Android]스피너,Spinner (0) | 2013.02.06 |
|---|---|
| [안드로이드,Android]WebView,웹뷰 (1) | 2013.02.05 |
| [안드로이드,Android]키보드 보이기, 숨기기 (0) | 2013.01.28 |
| [안드로이드,Android]로그,LOG (0) | 2013.01.25 |
| [안드로이드,Android]메뉴 옵션 (0) | 2013.01.24 |