package com.thistimebd.web.clock;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AnalogClock;
import android.widget.TextClock;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private TextClock textClock;
private AnalogClock analogClock;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textClock=(TextClock) findViewById(R.id.textClockId);
analogClock=(AnalogClock) findViewById(R.id.analogClockId);
analogClock.setOnClickListener(this);
textClock.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if(v.getId()==R.id.analogClockId){
Toast.makeText(MainActivity.this,"Analog clock",Toast.LENGTH_SHORT).show();
} if(v.getId()==R.id.textClockId){
Toast.makeText(MainActivity.this,"Text clock",Toast.LENGTH_SHORT).show();
}
}
}
activity_main.xml
<?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:padding="10dp"
android:gravity="center"
tools:context="com.thistimebd.web.clock.MainActivity">
<AnalogClock
android:id="@+id/analogClockId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="#63e1ac"
/>
<TextClock
android:id="@+id/textClockId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
thistimebd Bangladesh Live online newsportal, education, Lifestyle, Health, Photography, gif image etc.
Make your own name or company name website | contact: thistimebd24@gmail.com
Copyright © 2020-2024 News Portal in Bangladesh - THISTIMEBD.COM. ALL Rights Reserved.