안드로이드의 버튼 링크
필그램
·2019. 1. 28. 11:12
package fit.korea2canada.com.jjfitv1;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageButton;
public class MainActivity extends AppCompatActivity {
ImageButton WalkingButton;
ImageButton WorkoutButton;
ImageButton WeightButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startService(new Intent(this, SensorListener.class));
setContentView(R.layout.activity_main);
WalkingButton = (ImageButton) findViewById(R.id.btnWalking);
WorkoutButton = (ImageButton) findViewById(R.id.btnWorkout);
WeightButton = (ImageButton) findViewById(R.id.btnWeight);
WalkingButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), StepperActivity.class);
startActivity(intent);
}
});
WorkoutButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), WorkoutActivity.class);
startActivity(intent);
}
});
WeightButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), WeightActivity.class);
startActivity(intent);
}
});
}
/*
public void onBtnClick(View v) {
Thread thread = new Thread(){
@Override
public void run() {
super.run();
for (int i=0; i<=100;) {
try{
sleep(1000);
} catch (InterruptedException e){
e.printStackTrace();
}
pgBar.setProgress(i);
i=i+10;
}
}
};
thread.start();
}
*/
}
[Activity_main]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1"
tools:context="fit.korea2canada.com.jjfitv1.MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Just Fit"
android:textAlignment="center"
android:textSize="50sp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageButton
android:id="@+id/btnWalking"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:background="@android:color/background_light"
android:paddingBottom="0dp"
android:scaleType="centerCrop"
app:srcCompat="@drawable/walkinglogo" />
<ImageButton
android:id="@+id/btnWorkout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:layout_weight="1"
android:background="@android:color/background_light"
android:scaleType="centerCrop"
app:srcCompat="@drawable/workoutlogo" />
<ImageButton
android:id="@+id/btnWeight"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:background="@android:color/background_light"
android:scaleType="centerCrop"
app:srcCompat="@drawable/weightlogo" />
</LinearLayout>
</LinearLayout>
반응형
'프로그래밍 > 모바일: iOS, Java, Android, Swift' 카테고리의 다른 글
[안드로이드 스튜디오] 웹뷰에서 자바스크립트 가능하게 (0) | 2019.03.21 |
---|---|
안드로이드 컬러 포지션 (0) | 2019.01.30 |
[Android] 라디오 버튼 선택 및 Switch조건문으로 실행법 (0) | 2017.10.21 |
[Java] 사용자 입력 받는 방법 (0) | 2017.10.21 |
[java] Opengl을 이용한 삼각형, 사각형 만들기 (0) | 2017.10.07 |