Commit 6334b47e authored by Ravishani W.M.S's avatar Ravishani W.M.S

Upload New File

parent 57ba1e22
package com.example.smart_pillow;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class Home extends AppCompatActivity implements View.OnClickListener{
private CardView alarm_card,sleep_card, music_card,light_card, health_card;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
// define the cards
alarm_card = (CardView) findViewById(R.id.alarmCardID);
sleep_card = (CardView) findViewById(R.id.sleepCardID);
music_card = (CardView) findViewById(R.id.musicCardID);
light_card = (CardView) findViewById(R.id.lightCardID);
health_card = (CardView) findViewById(R.id.healthCardID);
//add click listener to cards
alarm_card.setOnClickListener(this);
sleep_card.setOnClickListener(this);
music_card.setOnClickListener(this);
light_card.setOnClickListener(this);
health_card.setOnClickListener(this);
}
@Override
public void onClick(View view) {
Intent i;
switch(view.getId())
{
case R.id.musicCardID:i=new Intent(this,Music.class); startActivity(i);break;
case R.id.lightCardID:i=new Intent(this,Light.class); startActivity(i); break;
default:break;
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment