Created
September 14, 2018 19:01
-
-
Save arslan74/c753a06f2b37b84513bc6ffe5556f824 to your computer and use it in GitHub Desktop.
Relative Layout Code Review
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" | |
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:padding="8dp" | |
tools:context=".RelativeLayoutExampleActivity"> | |
<TextView android:id="@+id/label" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:textSize="18sp" | |
android:text="Email" /> | |
<EditText android:id="@+id/inputEmail" | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" | |
android:layout_below="@id/label" /> | |
<Button android:id="@+id/login" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_below="@id/inputEmail" | |
android:layout_alignParentLeft="true" | |
android:layout_marginRight="10px" | |
android:text="Login" /> | |
<Button android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:id="@+id/cancel" | |
android:layout_toRightOf="@id/login" | |
android:layout_alignTop="@id/login" | |
android:text="Cancel" /> | |
<Button android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:id="@+id/register" | |
android:layout_alignParentBottom="true" | |
android:text="Register new Account" | |
android:layout_centerHorizontal="true"/> | |
</RelativeLayout> |
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.arslan.bs_app; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.Toast; | |
public class RelativeLayoutExampleActivity extends AppCompatActivity implements View.OnClickListener { | |
//views fields | |
private Button loginButton , registerButton , cancelButton; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_linear_layout_example); | |
loginButton = findViewById(R.id.login); | |
registerButton = findViewById(R.id.register); | |
cancelButton = findViewById(R.id.cancel); | |
loginButton.setOnClickListener(this); | |
registerButton.setOnClickListener(this); | |
cancelButton.setOnClickListener(this); | |
} | |
@Override | |
public void onClick(View view) { | |
switch (view.getId()){ | |
case R.id.login: | |
Toast.makeText(this , "No Logic for login",Toast.LENGTH_SHORT).show(); | |
break; | |
case R.id.cancel: | |
finish(); | |
break; | |
case R.id.register: | |
Toast.makeText(this , "No Logic for register",Toast.LENGTH_SHORT).show(); | |
break; | |
default: | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment