<--! 안드로이드의 버튼 링크 -->

안드로이드의 버튼 링크

필그램

·

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>




반응형