[/code]
Main.axml
">
[/code]
Main.axml[code]<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/darker_gray"
android:weightSum="100"
android:minWidth="25px"
android:minHeight="25px">
<TextView
android:text="LOGIN"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="25sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/textView1" />
<EditText
android:id="@+id/txtusername"
android:layout_width="fill_parent"
android:textColorHint="@android:color/black"
android:hint="Username"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/txtpwd"
android:layout_width="fill_parent"
android:textColorHint="@android:color/black"
android:hint="Password"
android:inputType="textPassword"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btnlogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/ButtonLogInStyle"
android:textSize="20sp"
android:text="Log In"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp" />
<Button
android:id="@+id/btnforgot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/ButtonLogInStyle"
android:textSize="15sp"
android:text="Forgot Password?"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:layout_marginBottom="20dp" />
<Button
android:id="@+id/btnregister"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/ButtonSignUpStyle"
android:textSize="20sp"
android:text="Register"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="170dp" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111" />
</LinearLayout>
">
[/code]
Main.axml[code]<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/darker_gray"
android:weightSum="100"
android:minWidth="25px"
android:minHeight="25px">
<TextView
android:text="LOGIN"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="25sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/textView1" />
<EditText
android:id="@+id/txtusername"
android:layout_width="fill_parent"
android:textColorHint="@android:color/black"
android:hint="Username"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/txtpwd"
android:layout_width="fill_parent"
android:textColorHint="@android:color/black"
android:hint="Password"
android:inputType="textPassword"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btnlogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/ButtonLogInStyle"
android:textSize="20sp"
android:text="Log In"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp" />
<Button
android:id="@+id/btnforgot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/ButtonLogInStyle"
android:textSize="15sp"
android:text="Forgot Password?"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:layout_marginBottom="20dp" />
<Button
android:id="@+id/btnregister"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/ButtonSignUpStyle"
android:textSize="20sp"
android:text="Register"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="170dp" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111" />
</LinearLayout>
">
[code]<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/darker_gray"
android:weightSum="100"
android:minWidth="25px"
android:minHeight="25px">
<TextView
android:text="LOGIN"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="25sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/textView1" />
<EditText
android:id="@+id/txtusername"
android:layout_width="fill_parent"
android:textColorHint="@android:color/black"
android:hint="Username"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/txtpwd"
android:layout_width="fill_parent"
android:textColorHint="@android:color/black"
android:hint="Password"
android:inputType="textPassword"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btnlogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/ButtonLogInStyle"
android:textSize="20sp"
android:text="Log In"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp" />
<Button
android:id="@+id/btnforgot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/ButtonLogInStyle"
android:textSize="15sp"
android:text="Forgot Password?"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:layout_marginBottom="20dp" />
<Button
android:id="@+id/btnregister"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/ButtonSignUpStyle"
android:textSize="20sp"
android:text="Register"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="170dp" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111" />
</LinearLayout>
[code]using Android.App;
using Android.Widget;
using Android.OS;
using Android.Gms.Ads;
using SQLite;
using System.IO;
using System;
namespace LogInApplication
{
[Activity(Label = "Log In Application", MainLauncher = true, Icon = "@mipmap/icon")]
public class MainActivity : Activity
{
protected AdView mAdView;
private InterstitialAd interstitialAds = null;
EditText txtusername;
EditText txtPassword;
Button btncreate;
Button btnsign;
Button btnedit;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
interstitialAds = new InterstitialAd(this);
mAdView = FindViewById<AdView>(Resource.Id.adView);
var adRequest = new AdRequest.Builder().Build();
mAdView.LoadAd(adRequest);
//setting unit id for interstitial ad
interstitialAds.AdUnitId = "ca - app - pub - 3113453000644941 / 8764416112";
//loading test ad using adrequest
interstitialAds.LoadAd(adRequest);
interstitialAds.AdListener = new AdListener(this);
btnsign = FindViewById<Button>(Resource.Id.btnlogin);
btncreate = FindViewById<Button>(Resource.Id.btnregister);
btnedit = FindViewById<Button>(Resource.Id.btnforgot);
txtusername = FindViewById<EditText>(Resource.Id.txtusername);
txtPassword = FindViewById<EditText>(Resource.Id.txtpwd);
btnsign.Click += Btnsign_Click;
btncreate.Click += Btncreate_Click;
btnedit.Click += Btnedit_Click;
CreateDB();
}
class AdListener : Android.Gms.Ads.AdListener
{
MainActivity main;
public AdListener(MainActivity innerMain)
{
main = innerMain;
}
public override void OnAdLoaded()
{
base.OnAdLoaded();
main.interstitialAds.Show();
}
}
private void Btncreate_Click(object sender, EventArgs e)
{
StartActivity(typeof(RegisterActivity));
}
private void Btnedit_Click(object sender, EventArgs e)
{
StartActivity(typeof(ForgotActivity));
}
private void Btnsign_Click(object sender, EventArgs e)
{
try
{
string dpPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "user.db3"); //Call Database
var db = new SQLiteConnection(dpPath);
var data = db.Table<LoginTable>(); //Call Table
var data1 = data.Where(x => x.username == txtusername.Text && x.password == txtPassword.Text).FirstOrDefault(); //Linq Query
if (data1 != null)
{
Toast.MakeText(this, "Login Success", ToastLength.Short).Show();
StartActivity(typeof(WelcomeActivity));
}
else
{
Toast.MakeText(this, "Username or Password invalid", ToastLength.Short).Show();
}
}
catch (Exception ex)
{
Toast.MakeText(this, ex.ToString(), ToastLength.Short).Show();
}
}
public string CreateDB()
{
var output = "";
output += "Creating Database if it doesn't exits";
string dpPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "user.db3"); //Create New Database
var db = new SQLiteConnection(dpPath);
output += "\n Database Created.....";
return output;
}
}
}[/code]
Main.axml[code]<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/darker_gray"
android:weightSum="100"
android:minWidth="25px"
android:minHeight="25px">
<TextView
android:text="LOGIN"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="25sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/textView1" />
<EditText
android:id="@+id/txtusername"
android:layout_width="fill_parent"
android:textColorHint="@android:color/black"
android:hint="Username"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/txtpwd"
android:layout_width="fill_parent"
android:textColorHint="@android:color/black"
android:hint="Password"
android:inputType="textPassword"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btnlogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/ButtonLogInStyle"
android:textSize="20sp"
android:text="Log In"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp" />
<Button
android:id="@+id/btnforgot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/ButtonLogInStyle"
android:textSize="15sp"
android:text="Forgot Password?"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:layout_marginBottom="20dp" />
<Button
android:id="@+id/btnregister"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/ButtonSignUpStyle"
android:textSize="20sp"
android:text="Register"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="170dp" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111" />
</LinearLayout>[/code]
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w