0% found this document useful (0 votes)
26 views3 pages

8 9CP

The document outlines steps to create a business card app and provides code samples: 1) It describes steps like defining UI elements in XML, changing themes, adding click listeners and time pickers. 2) The MainActivity code sample implements these steps, including setting onClick listeners and displaying selected time. 3) The activity_main.xml layout sample defines UI elements like text views and buttons. 4) Strings.xml contains text for UI elements like titles and buttons. Sample output shows the app is producing the correct output.

Uploaded by

Adarsh Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views3 pages

8 9CP

The document outlines steps to create a business card app and provides code samples: 1) It describes steps like defining UI elements in XML, changing themes, adding click listeners and time pickers. 2) The MainActivity code sample implements these steps, including setting onClick listeners and displaying selected time. 3) The activity_main.xml layout sample defines UI elements like text views and buttons. 4) Strings.xml contains text for UI elements like titles and buttons. Sample output shows the app is producing the correct output.

Uploaded by

Adarsh Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

770530-8-5CP AID: 8522 | 28/12/2021

Project Plan:

Consider the following steps to create the business card app:

 Define the one ImageView, three TextView and one Button in activity_main.xml file
to create the interface of the first App.
 Go to Theme.xml file and replace the default theme with black theme.
 Use the ImageDescription property to describe the description of the image.
 Create the instance of button and use the setOnClickListener to define
onClick() method to handle the button click. Call the TimePickerDialog()
with in the onClick() method to show the date picker when the button is clicked.
 Add the onTimeSet() method to obtain the time selected by the user and use the
setText() method to display the obtained result.

Programs:

The source code of MainActivity.java file is given below that implements the above-
mentioned method to provide the functionality to the interface which is created by
activity_main.xml file.

package com.example.wildgingerdinnerdelivarytabletapp;
import androidx.appcompat.app.AppCompatActivity;
import android.app.TimePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.TimePicker;
import java.util.Calendar;
public class MainActivityextends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn=(Button) findViewById(R.id.picker);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new TimePickerDialog(MainActivity.this, time,
c.get(Calendar.HOUR_OF_DAY),c.get(Calendar.MINUTE),true).sho
w();
}
});
}
final Calendar j = Calendar.getInstance();
TimePickerDialog.OnTimeSetListenertime=new
TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePickertimePicker, int i, int i1) {
j.set(Calendar.HOUR_OF_DAY,i);
j.set(Calendar.MINUTE,i1);
TextViewtextView= findViewById(R.id.output);
textView.setText("Your Selected Date is"+j.getTime());
}
};
}

The source code of activity_main.xml is given below that provide the interface to the
main screen.

<?xml version="1.0" encoding="utf-8"?>


<androidx.constraintlayout.widget.ConstraintLayout
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"
tools:context=".MainActivity">

<TableLayout
android:id="@+id/tableLayout"
android:layout_width="267dp"
android:layout_height="1354dp"
android:layout_marginStart="1dp"
android:layout_marginEnd="1dp"
android:background="@drawable/img"
app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toStartOf="@+id/linearLayout2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0">

</TableLayout>

<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="1dp"
android:layout_marginBottom="1dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toEndOf="@+id/tableLayout"
app:layout_constraintTop_toTopOf="parent">

<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/purple_200"
android:text="@string/title"
android:textColor="@color/black"
android:textSize="34sp"
android:textStyle="normal" />

<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/text1"
android:textSize="24sp" />

<Button
android:id="@+id/picker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/btn1"
android:textSize="24sp" />

<TextView
android:id="@+id/output"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp" />

</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

The source code of string.xml is given below that contains the text which appeared on the
interface of the app.

<resources>
<string name="app_name"> Wild Ginger Dinner Delivery
Tablet App</string>
<string name="title"> Wild Ginger Dinner Delivery
</string>
<string name="text1"> Wild ginger is a member of the
birthwort family . Deep green, hirsute,heart shaped leaves
with distinctive, prominent venation,and unique purplish-
brown colored flowers, with three long,radiating calyx
segments, distinguish the species.</string>
<string name="btn1">BOOK THE RESERVATION</string>

</resources>

Sample Output:
Hence, it can be concluded that App has produced the correct output.

You might also like