Activity XML
Activity XML
Activity XML
<EditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"
android:textSize="24sp" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/name"
android:hint="Password"
android:textSize="24sp" />
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/password"
android:lineSpacingExtra="36sp"
android:layout_centerHorizontal="true"
android:text="Sign in" />
</RelativeLayout>
Mainactivity.java
package com.example.bishal_2.myapplication;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Username = (EditText)findViewById(R.id.name);
Password = (EditText)findViewById(R.id.password);
Login = (Button)findViewById(R.id.btn);
Login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
validate(Username.getText().toString(), Password.getText().toString());
}
});
Main2activity
package com.example.bishal_2.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
}
}
Activity_main2.xml
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="This is second activity"
android:textSize="30sp" />
</RelativeLayout>