Android application with complete code:
First page |
The xml 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"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/trans" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="162dp"
android:gravity="center"
android:layout_marginTop="100dp"
android:background="@drawable/transp">
<EditText
android:id="@+id/Username"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text="Username" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/password"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:ems="10"
android:inputType="textPassword"
android:text="Password" />
<Button
android:id="@+id/button2"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@drawable/liginbtn"
android:text="Exit" />
<Button
android:id="@+id/one"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/button2"
android:background="@drawable/liginbtn"
android:text="Enter" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/trans" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="162dp"
android:gravity="center"
android:layout_marginTop="100dp"
android:background="@drawable/transp">
<EditText
android:id="@+id/Username"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text="Username" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/password"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:ems="10"
android:inputType="textPassword"
android:text="Password" />
<Button
android:id="@+id/button2"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@drawable/liginbtn"
android:text="Exit" />
<Button
android:id="@+id/one"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/button2"
android:background="@drawable/liginbtn"
android:text="Enter" />
</RelativeLayout>
</LinearLayout>
second page |
Here the 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"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:orientation="horizontal"
android:background="@drawable/trans">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/layer13" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Janmejoy"
android:layout_marginLeft="20dp"/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:orientation="horizontal"
android:background="@drawable/trans">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/layer13" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Janmejoy"
android:layout_marginLeft="20dp"/>
</LinearLayout>
Here the code begins.......
"MainActivity"
package com.example.example;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends Activity {
Button Login,Exit;
EditText username,password;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.sample);
Login=(Button)findViewById(R.id.one);
Exit=(Button)findViewById(R.id.button2);
username=(EditText)findViewById(R.id.Username);
password=(EditText)findViewById(R.id.password);
Login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent=new Intent(MainActivity.this,First.class);
startActivity(intent);
finish();
}
});
Exit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
System.exit(0);
finish();
}
});
}
}
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends Activity {
Button Login,Exit;
EditText username,password;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.sample);
Login=(Button)findViewById(R.id.one);
Exit=(Button)findViewById(R.id.button2);
username=(EditText)findViewById(R.id.Username);
password=(EditText)findViewById(R.id.password);
Login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent=new Intent(MainActivity.this,First.class);
startActivity(intent);
finish();
}
});
Exit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
System.exit(0);
finish();
}
});
}
}
"NextActivity:
package com.example.example;
import android.app.Activity;
import android.os.Bundle;
import android.app.Activity;
import android.os.Bundle;
public class First extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.intentpage);
}
}
You must add the next activity in Manifest file
<activity android:name=".First" android:label="@string/app_name" > </activity>
1 comment:
Great post. I love the idea of a portable air conditioner that doesn't need to be vented to the outside and you explain it pretty well here, thanks! Kindly also discuss with my website. Exit intent
Post a Comment