This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:paddingLeft="16dp" | |
android:paddingRight="16dp" > | |
<TextView | |
android:id="@+id/view1" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.helloworld; | |
import androidx.appcompat.app.AppCompatActivity; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.widget.TextView; | |
import java.util.Calendar; | |
public class DetailsActivity extends AppCompatActivity { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(myDOB.compareTo(now)<=0) | |
textview.setText("You were born on "+strDays[myDOB.get(Calendar.DAY_OF_WEEK)-1]); | |
else | |
textview.setText("No wait you cant be here now and be born in the future."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myDOB.set(year,month,day); | |
now.set(curYear,curMonth,curday); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int curYear=now.get(Calendar.YEAR); | |
int curMonth=now.get(Calendar.MONTH); | |
int curday=now.get(Calendar.DATE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Calendar myDOB=Calendar.getInstance(); | |
Calendar now=Calendar.getInstance(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int year=Integer.parseInt(dob.substring(6,10)); | |
int month=Integer.parseInt(dob.substring(3,5))-1; | |
int day=Integer.parseInt(dob.substring(0,2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:paddingLeft="16dp" | |
android:paddingRight="16dp"> | |
<TextView | |
android:id="@+id/day" | |
android:layout_height="wrap_content" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void sendDOB(View view){ | |
Intent intent=new Intent(this,DetailsActivity.class); | |
if (dob.matches("")) | |
Toast.makeText(this, "Give me your correct birthday", Toast.LENGTH_SHORT).show(); | |
else { | |
intent.putExtra("dateOfBirth",dob); | |
startActivity(intent); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (dobField.getText().length()<10 || dobField.getText().length()>10) { | |
dob=""; | |
message.setText(("Hey " + nameField.getText().toString() + | |
". You may wish to enter your birthday correctly.Your current birthday seems to be invalid")); | |
} | |
else { | |
dob=dobField.getText().toString(); | |
message.setText(("Hey " + nameField.getText().toString() + ". You know " + monthsArray[Integer.parseInt(dobField.getText().toString().substring(3, 5)) - 1] + | |
" is a really good month to start your journey on our planet.")); | |
} |
NewerOlder