Famer Buddy
Famer Buddy
Famer Buddy
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.os.Bundle;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
super.onStart();
super.onRestart();
super.onPause();
super.onStop();
super.onDestroy();
}
Prac 7a
activity_main.xml
<RelativeLayout 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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:stretchColumns="1">
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="First Name"></TextView>
<EditText
android:id="@+id/etFName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp">
<requestFocus></requestFocus>
</EditText>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Last Name"></TextView>
<EditText
android:id="@+id/etLName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"></EditText>
</TableRow>
</TableLayout>
<Button
android:id="@+id/btnSubmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Submit"></Button>
</LinearLayout>
MainActivity.java
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.QuickContactBadge;
import android.widget.TextView;
import android.widget.Toast;
import java.util.Random;
EditText etFName;
EditText etLName;
Button btnSubmit;
@Override
setContentView(R.layout.activity_main);
btnSubmit.setOnClickListener(new View.OnClickListener() {
@Override
intent.putExtra("fname", etFName.getText().toString());
intent.putExtra("lname", etLName.getText().toString());
startActivity(intent);
});
activity_view2.xml
<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"
tools:context=".ViewActivity">
<TextView
android:id="@+id/tvView"
android:layout_width="400dp"
android:layout_height="85dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:text="Output"
android:textColor="@android:color/bright_blue"
android:textSize="24sp"
android:textStyle="bold"></TextView>
</LinearLayout>
ViewActivity.java
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
TextView tvView;
@Override
setContentView(R.layout.activity_view);