Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".SecondActivity"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
16 changes: 5 additions & 11 deletions app/src/main/java/com/training/simpleloginform/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.training.simpleloginform;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
Expand All @@ -9,7 +10,6 @@
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;


import java.util.ArrayList;
Expand All @@ -28,8 +28,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private AutoCompleteTextView usernameEditText;
private EditText passwordEditText;
private Button submitButton;
private TextView usernameDetailsTextView;
private TextView passwordDetailsTextView;
private Button resetButton;

Names names = new Names();
Expand All @@ -40,11 +38,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

usernameEditText = findViewById(R.id.user_name_edit_text);
passwordEditText = findViewById(R.id.password_edit_text);
usernameDetailsTextView = findViewById(R.id.username_details_textview);
passwordDetailsTextView = findViewById(R.id.password_details_textview);
submitButton = findViewById(R.id.submit_button);
resetButton = findViewById(R.id.reset_button);

Expand All @@ -58,13 +53,14 @@ protected void onCreate(Bundle savedInstanceState) {

}


@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.submit_button:
String username = usernameEditText.getText().toString();
String password = passwordEditText.getText().toString();
Intent intent = new Intent(this, SecondActivity.class);
intent.putExtra("username", usernameEditText.getText().toString());
intent.putExtra("password", passwordEditText.getText().toString());
startActivity(intent);

usernameDetailsTextView.setText(username);
passwordDetailsTextView.setText(password);
Expand All @@ -84,8 +80,6 @@ public void onClick(View view) {
public void setResetButton() {
usernameEditText.setText("");
passwordEditText.setText("");
usernameDetailsTextView.setText("");
passwordDetailsTextView.setText("");

}

Expand Down
26 changes: 26 additions & 0 deletions app/src/main/java/com/training/simpleloginform/SecondActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.training.simpleloginform;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;


public class SecondActivity extends AppCompatActivity {
private TextView usernameDetailsTextView;
private TextView passwordDetailsTextView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
usernameDetailsTextView = findViewById(R.id.username_details_textview);
passwordDetailsTextView = findViewById(R.id.password_details_textview);


usernameDetailsTextView.setText(getIntent().getStringExtra("username"));
passwordDetailsTextView.setText(getIntent().getStringExtra("password"));


}
}

22 changes: 2 additions & 20 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,32 +75,14 @@
android:id="@+id/reset_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="@dimen/general_margin"
android:layout_marginTop="@dimen/general_margin"
android:layout_marginRight="@dimen/general_margin"
android:layout_weight="1"
android:background="@android:color/holo_green_dark"
android:text="@string/reset_button_string"
android:textStyle="bold" />

</LinearLayout>


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/general_margin"
android:orientation="vertical">

<TextView
android:id="@+id/username_details_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/password_details_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</LinearLayout>

</LinearLayout>
60 changes: 60 additions & 0 deletions app/src/main/res/layout/activity_second.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/margin"
android:orientation="vertical"
tools:context=".SecondActivity">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">


<TextView
android:id="@+id/username_label_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin"
android:hint="@string/username"
android:textSize="@dimen/txt_size"
android:textStyle="bold" />


<TextView
android:id="@+id/username_details_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin"
android:textSize="@dimen/txt_size"
android:textStyle="bold" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:id="@+id/password_label_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin"
android:hint="@string/password"
android:textSize="@dimen/txt_size"
android:textStyle="bold" />


<TextView
android:id="@+id/password_details_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin"
android:textSize="@dimen/txt_size"
android:textStyle="bold" />

</LinearLayout>

</LinearLayout>
3 changes: 3 additions & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="general_margin">20dp</dimen>
<dimen name="margin">20dp</dimen>
<dimen name="margin">20dp</dimen>
<dimen name="txt_size">20sp</dimen>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
<string name="password_label_string">Password</string>
<string name="submit_button_string">Submit</string>
<string name="reset_button_string">reset</string>
<string name="username">Username :</string>
<string name="password">Password :</string>
</resources>