SlideShare a Scribd company logo
1 of 24
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
Android Application Development Training Tutorial
For more info visit
http://www.zybotech.in
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
JAVA
AddEmployee
publicclass AddEmployee extendsActivity{
EditText txtName;
EditText txtAge;
TextViewtxtEmps;
DatabaseHelperdbHelper;
SpinnerspinDept;
@Override
public voidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.addemployee);
txtName=(EditText)findViewById(R.id.txtName);
txtAge=(EditText)findViewById(R.id.txtAge);
txtEmps=(TextView)findViewById(R.id.txtEmps);
spinDept=(Spinner)findViewById(R.id.spinDept);
}
@Override
publicvoid onStart()
{
try
{
super.onStart();
dbHelper=newDatabaseHelper(this);
txtEmps.setText(txtEmps.getText()+String.valueOf(dbHelper.getEmployeeCount()));
Cursor c=dbHelper.getAllDepts();
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
startManagingCursor(c);
//SimpleCursorAdapterca=new SimpleCursorAdapter(this,android.R.layout.simple_spinner_item,c,
new String []{DatabaseHelper.colDeptName},newint[]{android.R.id.text1});
SimpleCursorAdapterca=newSimpleCursorAdapter(this,R.layout.deptspinnerrow,c,newString []
{DatabaseHelper.colDeptName,"_id"},newint[]{R.id.txtDeptName});
//ca.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinDept.setAdapter(ca);
spinDept.setOnItemSelectedListener(newOnItemSelectedListener() {
publicvoid onItemSelected(AdapterView<?>parent,ViewselectedView,
int position,longid) {
// TODO Auto-generatedmethodstub
}
publicvoid onNothingSelected(AdapterView<?>arg0) {
// TODO Auto-generatedmethodstub
}
});
//never close cursor
}
catch(Exceptionex)
{
CatchError(ex.toString());
}
}
publicvoid btnAddEmp_Click(Viewview)
{
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
booleanok=true;
try
{
Spannable spn=txtAge.getText();
String name=txtName.getText().toString();
int age=Integer.valueOf(spn.toString());
int deptID=Integer.valueOf((int)spinDept.getSelectedItemId());
Employee emp=newEmployee(name,age,deptID);
dbHelper.AddEmployee(emp);
}
catch(Exceptionex)
{
ok=false;
CatchError(ex.toString());
}
finally
{
if(ok)
{
//NotifyEmpAdded();
Alerts.ShowEmpAddedAlert(this);
txtEmps.setText("Numberofemployees"+String.valueOf(dbHelper.getEmployeeCount()));
}
}
}
void CatchError(String Exception)
{
Dialog diag=newDialog(this);
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
diag.setTitle("AddnewEmployee");
TextViewtxt=newTextView(this);
txt.setText(Exception);
diag.setContentView(txt);
diag.show();
}
void NotifyEmpAdded()
{
Dialog diag=newDialog(this);
diag.setTitle("AddnewEmployee");
TextViewtxt=newTextView(this);
txt.setText("Employee AddedSuccessfully");
diag.setContentView(txt);
diag.show();
try {
diag.wait(1000);
} catch (InterruptedExceptione) {
// TODO Auto-generatedcatchblock
CatchError(e.toString());
}
diag.notify();
diag.dismiss();
}}
Alerts
publicclass Alerts {
publicstatic voidShowEmpAddedAlert(Contextcon)
{
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
AlertDialog.Builderbuilder=newAlertDialog.Builder(con);
builder.setTitle("AddnewEmployee");
builder.setIcon(android.R.drawable.ic_dialog_info);
DialogListnerlistner=newDialogListner();
builder.setMessage("Employee Addedsuccessfully");
builder.setPositiveButton("ok",listner);
AlertDialogdiag=builder.create();
diag.show();
}
publicstatic AlertDialogShowEditDialog(final Contextcon,final Employee emp)
{
AlertDialog.Builderb=newAlertDialog.Builder(con);
b.setTitle("Employee Details");
LayoutInflater li=LayoutInflater.from(con);
Viewv=li.inflate(R.layout.editdialog,null);
b.setIcon(android.R.drawable.ic_input_get);
b.setView(v);
final TextViewtxtName=(TextView)v.findViewById(R.id.txtDelName);
final TextViewtxtAge=(TextView)v.findViewById(R.id.txtDelAge);
final Spinnerspin=(Spinner)v.findViewById(R.id.spinDiagDept);
Utilities.ManageDeptSpinner(con,spin);
for(inti=0;i<spin.getCount();i++)
{
long id=spin.getItemIdAtPosition(i);
if(id==emp.getDept())
{
spin.setSelection(i,true);
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
break;
}
}
txtName.setText(emp.getName());
txtAge.setText(String.valueOf(emp.getAge()));
b.setPositiveButton("Modify",newOnClickListener() {
publicvoid onClick(DialogInterface dialog,intwhich) {
// TODO Auto-generatedmethodstub
emp.setName(txtName.getText().toString());
emp.setAge(Integer.valueOf(txtAge.getText().toString()));
emp.setDept((int)spin.getItemIdAtPosition(spin.getSelectedItemPosition()));
try
{
DatabaseHelperdb=new DatabaseHelper(con);
db.UpdateEmp(emp);
}
catch(Exceptionex)
{
CatchError(con, ex.toString());
}
}
});
b.setNeutralButton("Delete",new OnClickListener(){
publicvoid onClick(DialogInterface dialog,intwhich) {
// TODO Auto-generatedmethodstub
DatabaseHelperdb=new DatabaseHelper(con);
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
db.DeleteEmp(emp);
}
});
b.setNegativeButton("Cancel",null);
return b.create();
//diag.show();
}
static public voidCatchError(Context con, String Exception)
{
Dialog diag=newDialog(con);
diag.setTitle("Error");
TextViewtxt=newTextView(con);
txt.setText(Exception);
diag.setContentView(txt);
diag.show();
}
}
DatabaseDemo
publicclass DatabaseDemo extendsTabActivity {
DatabaseHelperdbHelper;
GridViewgrid;
TextViewtxtTest;
/** Calledwhenthe activity is first created.*/
@Override
public voidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
SetupTabs();
}
@Override
public booleanonCreateOptionsMenu(Menumenu)
{
menu.add(1,1, 1, "Add Employee");
return true;
}
public booleanonOptionsItemSelected(MenuItemitem)
{
switch (item.getItemId())
{
//Add employee
case 1:
Intent addIntent=newIntent(this,AddEmployee.class);
startActivity(addIntent);
break;
}
super.onOptionsItemSelected(item);
return false;
}
void SetupTabs()
{
TabHost host=getTabHost();
TabHost.TabSpec spec=host.newTabSpec("tag1");
Intentin1=new Intent(this,AddEmployee.class);
spec.setIndicator("AddEmployee");
spec.setContent(in1);
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
TabHost.TabSpec spec2=host.newTabSpec("tag2");
Intentin2=new Intent(this,GridList.class);
spec2.setIndicator("Employees");
spec2.setContent(in2);
host.addTab(spec);
host.addTab(spec2);
}}
DataBaseHelper
publicclass DatabaseHelper extendsSQLiteOpenHelper{
static final String dbName="demoDB";
static final String employeeTable="Employees";
static final String colID="EmployeeID";
static final String colName="EmployeeName";
static final String colAge="Age";
static final String colDept="Dept";
static final String deptTable="Dept";
static final String colDeptID="DeptID";
static final String colDeptName="DeptName";
static final String viewEmps="ViewEmps";
publicDatabaseHelper(Contextcontext) {
super(context,dbName,null,33);
// TODO Auto-generatedconstructorstub
}
@Override
publicvoid onCreate(SQLiteDatabase db) {
// TODO Auto-generatedmethodstub
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
db.execSQL("CREATETABLE "+deptTable+" ("+colDeptID+" INTEGER PRIMARY KEY , "+
colDeptName+" TEXT)");
db.execSQL("CREATETABLE "+employeeTable+" ("+colID+" INTEGERPRIMARYKEY AUTOINCREMENT,
"+colName+" TEXT, "+colAge+" Integer,"+colDept+" INTEGERNOT NULL ,FOREIGN KEY ("+colDept+") REFERENCES
"+deptTable+" ("+colDeptID+"));");
db.execSQL("CREATETRIGGERfk_empdept_deptid" + " BEFORE INSERT "+" ON"+employeeTable+" FOR
EACH ROW BEGIN"+" SELECT CASE WHEN ((SELECT "+colDeptID+" FROM "+deptTable+" WHERE
"+colDeptID+"=new."+colDept+" ) ISNULL)"+" THEN RAISE (ABORT,'ForeignKeyViolation') END;"+ " END;");
db.execSQL("CREATEVIEW "+viewEmps+" ASSELECT "+employeeTable+"."+colID+" AS_id,"+
" "+employeeTable+"."+colName+","+ " "+employeeTable+"."+colAge+","+"
"+deptTable+"."+colDeptName+""+" FROM"+employeeTable+" JOIN"+deptTable+" ON
"+employeeTable+"."+colDept+" ="+deptTable+"."+colDeptID );
//Inserts pre-defineddepartments
InsertDepts(db);
}
@Override
publicvoid onUpgrade(SQLiteDatabase db,int oldVersion,intnewVersion) {
// TODO Auto-generatedmethodstub
db.execSQL("DROPTABLE IF EXISTS "+employeeTable);
db.execSQL("DROPTABLE IF EXISTS "+deptTable);
db.execSQL("DROPTRIGGERIF EXISTS dept_id_trigger");
db.execSQL("DROPTRIGGERIF EXISTS dept_id_trigger22");
db.execSQL("DROPTRIGGERIF EXISTS fk_empdept_deptid");
db.execSQL("DROPVIEW IFEXISTS "+viewEmps);
onCreate(db);
}
void AddEmployee(Employee emp)
{
SQLiteDatabase db= this.getWritableDatabase();
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
ContentValuescv=newContentValues();
cv.put(colName,emp.getName());
cv.put(colAge, emp.getAge());
cv.put(colDept,emp.getDept());
//cv.put(colDept,2);
db.insert(employeeTable,colName,cv);
db.close();
}
int getEmployeeCount()
{
SQLiteDatabase db=this.getWritableDatabase();
Cursor cur= db.rawQuery("Select*from "+employeeTable,null);
int x= cur.getCount();
cur.close();
return x;
}
Cursor getAllEmployees()
{
SQLiteDatabase db=this.getWritableDatabase();
//Cursor cur= db.rawQuery("Select"+colID+" as_id , "+colName+","+colAge+" from
"+employeeTable,newString[]{});
Cursor cur= db.rawQuery("SELECT * FROM "+viewEmps,null);
return cur;
}
Cursor getAllDepts()
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
{
SQLiteDatabase db=this.getReadableDatabase();
Cursor cur=db.rawQuery("SELECT "+colDeptID+" as _id, "+colDeptName+" from"+deptTable,new
String [] {});
return cur;
}
void InsertDepts(SQLiteDatabase db)
{
ContentValuescv=newContentValues();
cv.put(colDeptID,1);
cv.put(colDeptName, "Sales");
db.insert(deptTable,colDeptID,cv);
cv.put(colDeptID,2);
cv.put(colDeptName,"IT");
db.insert(deptTable,colDeptID,cv);
cv.put(colDeptID,3);
cv.put(colDeptName,"HR");
db.insert(deptTable,colDeptID,cv);
db.insert(deptTable,colDeptID,cv);
}
publicString GetDept(intID)
{
SQLiteDatabase db=this.getReadableDatabase();
String[]params=new String[]{String.valueOf(ID)};
Cursor c=db.rawQuery("SELECT "+colDeptName+" FROM"+deptTable+" WHERE
"+colDeptID+"=?",params);
c.moveToFirst();
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
int index=c.getColumnIndex(colDeptName);
return c.getString(index);
}
publicCursor getEmpByDept(StringDept)
{
SQLiteDatabase db=this.getReadableDatabase();
String [] columns=newString[]{"_id",colName,colAge,colDeptName};
Cursor c=db.query(viewEmps,columns,colDeptName+"=?",newString[]{Dept},null, null,null);
return c;
}
public intGetDeptID(StringDept)
{
SQLiteDatabase db=this.getReadableDatabase();
Cursor c=db.query(deptTable,newString[]{colDeptID+" as _id",colDeptName},colDeptName+"=?",
new String[]{Dept},null,null,null);
//Cursor c=db.rawQuery("SELECT "+colDeptID+" as _id FROM "+deptTable+" WHERE
"+colDeptName+"=?",newString[]{Dept});
c.moveToFirst();
return c.getInt(c.getColumnIndex("_id"));
}
publicint UpdateEmp(Employee emp)
{
SQLiteDatabase db=this.getWritableDatabase();
ContentValuescv=newContentValues();
cv.put(colName,emp.getName());
cv.put(colAge,emp.getAge());
cv.put(colDept,emp.getDept());
return db.update(employeeTable,cv,colID+"=?",newString []{String.valueOf(emp.getID())});
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
}
publicvoid DeleteEmp(Employee emp)
{
SQLiteDatabase db=this.getWritableDatabase();
db.delete(employeeTable,colID+"=?",newString[]{String.valueOf(emp.getID())});
db.close();}}
DialogListener
publicclass DialogListnerimplementsandroid.content.DialogInterface.OnClickListener{
publicDialogListner()
{
}
publicvoid onClick(DialogInterface dialog,intwhich) {
// TODO Auto-generatedmethodstub
} }
Employee
publicclass Employee {
int _id;
String _name;
int _age;
int _dept;
publicEmployee(StringName,intAge,intDept)
{
this._name=Name;
this._age=Age;
this._dept=Dept;
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
}
publicEmployee(StringName,intAge)
{
this._name=Name;
this._age=Age;
}
publicint getID()
{
return this._id;
}
publicvoid SetID(intID)
{
this._id=ID;
}
publicString getName()
{
return this._name;
}
publicint getAge()
{
return this._age;
}
publicvoid setName(StringName)
{
this._name=Name;
}
publicvoid setAge(intAge)
{
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
this._age=Age;
}
publicvoid setDept(intDept)
{
this._dept=Dept;
}
publicString getDeptName(Contextcon,intDept)
{
return newDatabaseHelper(con).GetDept(Dept);
}
publicint getDept()
{
return this._dept;
}
}
GridList
publicclass GridListextendsActivity {
DatabaseHelperdbHelper;
static public GridViewgrid;
TextViewtxtTest;
SpinnerspinDept1;
/** Calledwhenthe activity is first created.*/
@Override
public voidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gridview);
grid=(GridView)findViewById(R.id.grid);
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
txtTest=(TextView)findViewById(R.id.txtTest);
spinDept1=(Spinner)findViewById(R.id.spinDept1);
Utilities.ManageDeptSpinner(this.getParent(),spinDept1);
final DatabaseHelperdb=new DatabaseHelper(this);
try
{
spinDept1.setOnItemSelectedListener(newOnItemSelectedListener() {
publicvoid onItemSelected(AdapterView<?>arg0,Viewarg1,
int arg2, longarg3) {
// TODO Auto-generatedmethodstub
LoadGrid();
//sca.notifyDataSetChanged();
}
publicvoid onNothingSelected(AdapterView<?>arg0) {
// TODO Auto-generatedmethodstub
}
});
}
catch(Exceptionex)
{
txtTest.setText(ex.toString());
}
try
{
grid.setOnItemClickListener(newOnItemClickListener()
{
publicvoid onItemClick(AdapterView<?>parent,Viewv,int position,
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
long id) {
// TODO Auto-generatedmethodstub
try
{
SQLiteCursorcr=(SQLiteCursor)parent.getItemAtPosition(position);
String name= cr.getString(cr.getColumnIndex(DatabaseHelper.colName));
int age=cr.getInt(cr.getColumnIndex(DatabaseHelper.colAge));
String Dept= cr.getString(cr.getColumnIndex(DatabaseHelper.colDeptName));
Employee emp=newEmployee(name,age,db.GetDeptID(Dept));
emp.SetID((int)id);
AlertDialogdiag= Alerts.ShowEditDialog(GridList.this,emp);
diag.setOnDismissListener(newOnDismissListener() {
publicvoid onDismiss(DialogInterface dialog) {
// TODO Auto-generatedmethodstub
txtTest.setText("dismissed");
//((SimpleCursorAdapter)grid.getAdapter()).notifyDataSetChanged();
LoadGrid();
}
});
diag.show();
}
catch(Exceptionex)
{
Alerts.CatchError(GridList.this,ex.toString());
}
}
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
});
}
catch(Exceptionex)
{
}
}
@Override
public voidonStart()
{
super.onStart();
//LoadGrid();
}
public voidLoadGrid()
{
dbHelper=newDatabaseHelper(this);
try
{
//Cursor c=dbHelper.getAllEmployees();
Viewv=spinDept1.getSelectedView();
TextViewtxt=(TextView)v.findViewById(R.id.txtDeptName);
String Dept=String.valueOf(txt.getText());
Cursor c=dbHelper.getEmpByDept(Dept);
startManagingCursor(c);
String [] from=newString
[]{DatabaseHelper.colName,DatabaseHelper.colAge,DatabaseHelper.colDeptName};
int [] to=new int[] {R.id.colName,R.id.colAge,R.id.colDept};
SimpleCursorAdaptersca=newSimpleCursorAdapter(this,R.layout.gridrow,c,from,to);
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
grid.setAdapter(sca);
}
catch(Exceptionex)
{
AlertDialog.Builderb=newAlertDialog.Builder(this);
b.setMessage(ex.toString());
b.show();
}
} }
Utilities
publicclass Utilities{
static public voidManageDeptSpinner(Contextcontext,Spinnerview)
{
DatabaseHelperdbHelper=newDatabaseHelper(context);
Cursor c=dbHelper.getAllDepts();
//context.startManagingCursor(c);
//SimpleCursorAdapterca=new SimpleCursorAdapter(this,android.R.layout.simple_spinner_item,c,new
String [] {DatabaseHelper.colDeptName},newint[]{android.R.id.text1});
SimpleCursorAdapterca=newSimpleCursorAdapter(context,R.layout.deptspinnerrow,c,newString []
{DatabaseHelper.colDeptName,"_id"},newint[]{R.id.txtDeptName});
view.setAdapter(ca); } }
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
XML
AddEmployee
<?xml version="1.0" encoding="utf-8" ?>
- <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height ="wrap_content">
- <LinearLayout android:layout_width="fill_parent" android:layout_height ="wrap_content"
android:orientation="vertical">
<TextView android:layout_width="wrap_content" android:layout_height ="wrap_content"
android:text="Employee Name" />
<EditText android:layout_width="fill_parent" android:layout_height ="fill_parent"
android:id="@+id/txtName" android:autoText="false" />
<TextView android:layout_width="wrap_content" android:layout_height ="wrap_content"
android:text="Employee Age" />
<EditText android:layout_width="fill_parent" android:layout_height ="fill_parent"
android:id="@+id/txtAge" android:inputType="number" android:digits="0123456789"
android:singleLine="true" />
<TextView android:layout_width="wrap_content" android:layout_height ="wrap_content"
android:text="Employee Dept" />
<Spinner android:layout_width="fill_parent" android:layout_height ="fill_parent"
android:id="@+id/spinDept" />
<Button android:layout_width="wrap_content" android:layout_height ="wrap_content"
android:id="@+id/btnAdd" android:text="Add Employee" android:onClick="btnAddEmp_Click" />
<TextView android:layout_width="wrap_content" android:layout_height ="wrap_content"
android:text="Number of employees" android:id="@+id/txtEmps" />
</LinearLayout >
</ScrollView>
editdialog
<?xml version="1.0" encoding="utf-8" ?>
- <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height ="wrap_content"
android:orientation="vertical">
- <TableRow>
<TextView android:layout_width="fill_parent" android:layout_height ="wrap_content"
android:text="Name:" />
<EditText android:layout_width="fill_parent" android:layout_height ="wrap_content"
android:id="@+id/txtDelName" />
</TableRow>
- <TableRow>
<TextView android:layout_width="fill_parent" android:layout_height ="wrap_content"
android:text="Age:" />
<EditText android:layout_width="fill_parent" android:layout_height ="wrap_content"
android:id="@+id/txtDelAge" />
</TableRow>
- <TableRow>
<Spinner android:layout_width="fill_parent" android:layout_height ="wrap_content"
android:id="@+id/spinDiagDept" android:layout_span="2" />
</TableRow>
<TableRow />
</TableLayout>
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
Deptspinnerrow
<?xml version="1.0" encoding="utf-8" ?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height ="wrap_content">
<TextView android:layout_width="fill_parent" android:layout_height ="wrap_content"
android:id="@+id/txtDeptName" android:textColor="#000" />
<TextView android:layout_width="fill_parent" android:layout_height ="wrap_content"
android:id="@+id/txtDeptID" android:textColor="#000" />
</LinearLayout >
Gridrow
<?xml version="1.0" encoding="utf-8" ?>
- <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
- <TableRow>
<TextView android:layout_width="50px" android:layout_height ="wrap_content"
android:id="@+id/colName" android:padding="5px" android:layout_weight ="1" />
<TextView android:layout_width="50px" android:layout_height ="wrap_content"
android:id="@+id/colAge" android:padding="5px" android:layout_weight="1" />
<TextView android:layout_width="50px" android:layout_height ="wrap_content"
android:id="@+id/colDept" android:padding="5px" android:layout_weight ="1" />
</TableRow>
</TableLayout>
Gridview
<?xml version="1.0" encoding="utf-8" ?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height ="wrap_content" android:id="@+id/tab1">
- <TableLayout android:layout_width="fill_parent" android:layout_height ="fill_parent">
- <TableRow>
<Spinner android:layout_width="fill_parent" android:layout_height ="fill_parent"
android:id="@+id/spinDept1" android:layout_span="3" />
</TableRow>
- <TableRow>
<TextView android:layout_width="fill_parent" android:layout_height ="fill_parent"
android:text="Employee Name" android:layout_weight ="1" />
<TextView android:layout_width="fill_parent" android:layout_height ="fill_parent"
android:text="Employee Age" android:layout_weight="1" />
<TextView android:layout_width="fill_parent" android:layout_height ="fill_parent"
android:text="Department" android:layout_weight ="1" />
</TableRow>
</TableLayout>
<GridView android:id="@+id/grid" android:layout_width="fill_parent"
android:layout_height ="fill_parent" android:numColumns="1" android:stretchMode="columnWidth"
/>
<TextView android:layout_width="fill_parent" android:layout_height ="fill_parent"
android:text="Employee Age" android:id="@+id/txtTest" />
</LinearLayout >
A7, StephanosTower,Eachamukku,Kakkanadu,Kochi
listview
<?xml version="1.0" encoding="utf-8" ?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height ="wrap_content">
<ListView android:id="@+id/listEmps" android:layout_width="fill_parent"
android:layout_height ="fill_parent" android:text="A semi-random button" />
<TextView android:layout_width="fill_parent" android:layout_height ="wrap_content"
android:text="@string/hello" android:id="@+id/txt" />
</LinearLayout >
Main
<?xml version="1.0" encoding="utf-8" ?>
- <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height ="fill_parent"
android:id="@android:id/tabhost">
<TabWidget android:layout_width="fill_parent" android:layout_height ="wrap_content"
android:id="@android:id/tabs" />
<FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent"
android:layout_height ="fill_parent" android:paddingTop="60px" />
</TabHost>

More Related Content

What's hot

node.js Module Development
node.js Module Developmentnode.js Module Development
node.js Module DevelopmentJay Harris
 
Test driven node.js
Test driven node.jsTest driven node.js
Test driven node.jsJay Harris
 
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und GebBDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und GebChristian Baranowski
 
groovy databases
groovy databasesgroovy databases
groovy databasesPaul King
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Tsuyoshi Yamamoto
 
Programming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorialProgramming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorialJeff Smith
 
Fun Teaching MongoDB New Tricks
Fun Teaching MongoDB New TricksFun Teaching MongoDB New Tricks
Fun Teaching MongoDB New TricksMongoDB
 
Spring data iii
Spring data iiiSpring data iii
Spring data iii명철 강
 
Py spark cheat sheet by cheatsheetmaker.com
Py spark cheat sheet by cheatsheetmaker.comPy spark cheat sheet by cheatsheetmaker.com
Py spark cheat sheet by cheatsheetmaker.comLam Hoang
 
第二讲 Python基礎
第二讲 Python基礎第二讲 Python基礎
第二讲 Python基礎juzihua1102
 
第二讲 预备-Python基礎
第二讲 预备-Python基礎第二讲 预备-Python基礎
第二讲 预备-Python基礎anzhong70
 
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜Takahiro Inoue
 
Testing multi outputformat based mapreduce
Testing multi outputformat based mapreduceTesting multi outputformat based mapreduce
Testing multi outputformat based mapreduceAshok Agarwal
 
Bubbles & Trees with jQuery
Bubbles & Trees with jQueryBubbles & Trees with jQuery
Bubbles & Trees with jQueryBastian Feder
 
Implementing CQRS and Event Sourcing with RavenDB
Implementing CQRS and Event Sourcing with RavenDBImplementing CQRS and Event Sourcing with RavenDB
Implementing CQRS and Event Sourcing with RavenDBOren Eini
 
Eddystone Beacons - Physical Web - Giving a URL to All Objects
Eddystone Beacons - Physical Web - Giving a URL to All ObjectsEddystone Beacons - Physical Web - Giving a URL to All Objects
Eddystone Beacons - Physical Web - Giving a URL to All ObjectsJeff Prestes
 
JRubyKaigi2010 Hadoop Papyrus
JRubyKaigi2010 Hadoop PapyrusJRubyKaigi2010 Hadoop Papyrus
JRubyKaigi2010 Hadoop PapyrusKoichi Fujikawa
 
AJUG April 2011 Cascading example
AJUG April 2011 Cascading exampleAJUG April 2011 Cascading example
AJUG April 2011 Cascading exampleChristopher Curtin
 

What's hot (20)

node.js Module Development
node.js Module Developmentnode.js Module Development
node.js Module Development
 
Test driven node.js
Test driven node.jsTest driven node.js
Test driven node.js
 
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und GebBDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
 
groovy databases
groovy databasesgroovy databases
groovy databases
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
 
Programming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorialProgramming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorial
 
Fun Teaching MongoDB New Tricks
Fun Teaching MongoDB New TricksFun Teaching MongoDB New Tricks
Fun Teaching MongoDB New Tricks
 
Unit testing pig
Unit testing pigUnit testing pig
Unit testing pig
 
Spring data iii
Spring data iiiSpring data iii
Spring data iii
 
Py spark cheat sheet by cheatsheetmaker.com
Py spark cheat sheet by cheatsheetmaker.comPy spark cheat sheet by cheatsheetmaker.com
Py spark cheat sheet by cheatsheetmaker.com
 
第二讲 Python基礎
第二讲 Python基礎第二讲 Python基礎
第二讲 Python基礎
 
第二讲 预备-Python基礎
第二讲 预备-Python基礎第二讲 预备-Python基礎
第二讲 预备-Python基礎
 
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
 
Testing multi outputformat based mapreduce
Testing multi outputformat based mapreduceTesting multi outputformat based mapreduce
Testing multi outputformat based mapreduce
 
Bubbles & Trees with jQuery
Bubbles & Trees with jQueryBubbles & Trees with jQuery
Bubbles & Trees with jQuery
 
Implementing CQRS and Event Sourcing with RavenDB
Implementing CQRS and Event Sourcing with RavenDBImplementing CQRS and Event Sourcing with RavenDB
Implementing CQRS and Event Sourcing with RavenDB
 
Eddystone Beacons - Physical Web - Giving a URL to All Objects
Eddystone Beacons - Physical Web - Giving a URL to All ObjectsEddystone Beacons - Physical Web - Giving a URL to All Objects
Eddystone Beacons - Physical Web - Giving a URL to All Objects
 
JRubyKaigi2010 Hadoop Papyrus
JRubyKaigi2010 Hadoop PapyrusJRubyKaigi2010 Hadoop Papyrus
JRubyKaigi2010 Hadoop Papyrus
 
AJUG April 2011 Cascading example
AJUG April 2011 Cascading exampleAJUG April 2011 Cascading example
AJUG April 2011 Cascading example
 
Swing database(mysql)
Swing database(mysql)Swing database(mysql)
Swing database(mysql)
 

Viewers also liked

Uml (unified modeling language)
Uml (unified modeling language)Uml (unified modeling language)
Uml (unified modeling language)nathanaelchandra
 
New Futures for Traditional Villages
New Futures for Traditional Villages New Futures for Traditional Villages
New Futures for Traditional Villages sneapa
 
Lori_Bittle_SME_BIO
Lori_Bittle_SME_BIOLori_Bittle_SME_BIO
Lori_Bittle_SME_BIOLori Bittle
 
Darrell O'Quinn December 2016
Darrell O'Quinn December 2016Darrell O'Quinn December 2016
Darrell O'Quinn December 2016Darrell O'Quinn
 
Mr. maherc.v Q.C_2
Mr. maherc.v Q.C_2Mr. maherc.v Q.C_2
Mr. maherc.v Q.C_2Maher Gad
 
μελπομένη σπυροπούλου 1051519_κατερίνα_παππά_1051522
μελπομένη σπυροπούλου 1051519_κατερίνα_παππά_1051522μελπομένη σπυροπούλου 1051519_κατερίνα_παππά_1051522
μελπομένη σπυροπούλου 1051519_κατερίνα_παππά_1051522Μελπομένη Σπυροπούλου
 
어느 HRD담당자가 아이와 교육적으로 노는 방법
어느 HRD담당자가 아이와 교육적으로 노는 방법어느 HRD담당자가 아이와 교육적으로 노는 방법
어느 HRD담당자가 아이와 교육적으로 노는 방법dcjin
 
What can cause the habitat to change
What can cause the habitat to changeWhat can cause the habitat to change
What can cause the habitat to changeaya alshaer
 
Beyond Town Gown
Beyond Town GownBeyond Town Gown
Beyond Town Gownsneapa
 

Viewers also liked (9)

Uml (unified modeling language)
Uml (unified modeling language)Uml (unified modeling language)
Uml (unified modeling language)
 
New Futures for Traditional Villages
New Futures for Traditional Villages New Futures for Traditional Villages
New Futures for Traditional Villages
 
Lori_Bittle_SME_BIO
Lori_Bittle_SME_BIOLori_Bittle_SME_BIO
Lori_Bittle_SME_BIO
 
Darrell O'Quinn December 2016
Darrell O'Quinn December 2016Darrell O'Quinn December 2016
Darrell O'Quinn December 2016
 
Mr. maherc.v Q.C_2
Mr. maherc.v Q.C_2Mr. maherc.v Q.C_2
Mr. maherc.v Q.C_2
 
μελπομένη σπυροπούλου 1051519_κατερίνα_παππά_1051522
μελπομένη σπυροπούλου 1051519_κατερίνα_παππά_1051522μελπομένη σπυροπούλου 1051519_κατερίνα_παππά_1051522
μελπομένη σπυροπούλου 1051519_κατερίνα_παππά_1051522
 
어느 HRD담당자가 아이와 교육적으로 노는 방법
어느 HRD담당자가 아이와 교육적으로 노는 방법어느 HRD담당자가 아이와 교육적으로 노는 방법
어느 HRD담당자가 아이와 교육적으로 노는 방법
 
What can cause the habitat to change
What can cause the habitat to changeWhat can cause the habitat to change
What can cause the habitat to change
 
Beyond Town Gown
Beyond Town GownBeyond Town Gown
Beyond Town Gown
 

Similar to Android Java SQLite Database Employee Management App Tutorial

CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on AndroidSven Haiges
 
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptGuy Royse
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCpootsbook
 
Bkbiet day2 & 3
Bkbiet day2 & 3Bkbiet day2 & 3
Bkbiet day2 & 3mihirio
 
Cascading Through Hadoop for the Boulder JUG
Cascading Through Hadoop for the Boulder JUGCascading Through Hadoop for the Boulder JUG
Cascading Through Hadoop for the Boulder JUGMatthew McCullough
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursorsinfo_zybotech
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursorsinfo_zybotech
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best PracticesYekmer Simsek
 
Leap Ahead with Redis 6.2
Leap Ahead with Redis 6.2Leap Ahead with Redis 6.2
Leap Ahead with Redis 6.2VMware Tanzu
 
Hadoop Integration in Cassandra
Hadoop Integration in CassandraHadoop Integration in Cassandra
Hadoop Integration in CassandraJairam Chandar
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js ModuleFred Chien
 
Vavr Java User Group Rheinland
Vavr Java User Group RheinlandVavr Java User Group Rheinland
Vavr Java User Group RheinlandDavid Schmitz
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryAlexandre Morgaut
 
All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...
All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...
All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...Altinity Ltd
 
Improving android experience for both users and developers
Improving android experience for both users and developersImproving android experience for both users and developers
Improving android experience for both users and developersPavel Lahoda
 
Droidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon Berlin
 

Similar to Android Java SQLite Database Employee Management App Tutorial (20)

CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 
Bkbiet day2 & 3
Bkbiet day2 & 3Bkbiet day2 & 3
Bkbiet day2 & 3
 
Cascading Through Hadoop for the Boulder JUG
Cascading Through Hadoop for the Boulder JUGCascading Through Hadoop for the Boulder JUG
Cascading Through Hadoop for the Boulder JUG
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursors
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursors
 
Clean coding-practices
Clean coding-practicesClean coding-practices
Clean coding-practices
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
Leap Ahead with Redis 6.2
Leap Ahead with Redis 6.2Leap Ahead with Redis 6.2
Leap Ahead with Redis 6.2
 
Hadoop Integration in Cassandra
Hadoop Integration in CassandraHadoop Integration in Cassandra
Hadoop Integration in Cassandra
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js Module
 
Vavr Java User Group Rheinland
Vavr Java User Group RheinlandVavr Java User Group Rheinland
Vavr Java User Group Rheinland
 
Advance java
Advance javaAdvance java
Advance java
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love Story
 
All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...
All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...
All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...
 
Improving android experience for both users and developers
Improving android experience for both users and developersImproving android experience for both users and developers
Improving android experience for both users and developers
 
Droidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon2013 android experience lahoda
Droidcon2013 android experience lahoda
 
How te bring common UI patterns to ADF
How te bring common UI patterns to ADFHow te bring common UI patterns to ADF
How te bring common UI patterns to ADF
 

More from info_zybotech

Android basics – dialogs and floating activities
Android basics – dialogs and floating activitiesAndroid basics – dialogs and floating activities
Android basics – dialogs and floating activitiesinfo_zybotech
 
How to create ui using droid draw
How to create ui using droid drawHow to create ui using droid draw
How to create ui using droid drawinfo_zybotech
 
Android database tutorial
Android database tutorialAndroid database tutorial
Android database tutorialinfo_zybotech
 
Android accelerometer sensor tutorial
Android accelerometer sensor tutorialAndroid accelerometer sensor tutorial
Android accelerometer sensor tutorialinfo_zybotech
 

More from info_zybotech (6)

Android basics – dialogs and floating activities
Android basics – dialogs and floating activitiesAndroid basics – dialogs and floating activities
Android basics – dialogs and floating activities
 
Notepad tutorial
Notepad tutorialNotepad tutorial
Notepad tutorial
 
How to create ui using droid draw
How to create ui using droid drawHow to create ui using droid draw
How to create ui using droid draw
 
Applications
ApplicationsApplications
Applications
 
Android database tutorial
Android database tutorialAndroid database tutorial
Android database tutorial
 
Android accelerometer sensor tutorial
Android accelerometer sensor tutorialAndroid accelerometer sensor tutorial
Android accelerometer sensor tutorial
 

Recently uploaded

ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 

Recently uploaded (20)

ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 

Android Java SQLite Database Employee Management App Tutorial

  • 1. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi Android Application Development Training Tutorial For more info visit http://www.zybotech.in
  • 2. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi JAVA AddEmployee publicclass AddEmployee extendsActivity{ EditText txtName; EditText txtAge; TextViewtxtEmps; DatabaseHelperdbHelper; SpinnerspinDept; @Override public voidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.addemployee); txtName=(EditText)findViewById(R.id.txtName); txtAge=(EditText)findViewById(R.id.txtAge); txtEmps=(TextView)findViewById(R.id.txtEmps); spinDept=(Spinner)findViewById(R.id.spinDept); } @Override publicvoid onStart() { try { super.onStart(); dbHelper=newDatabaseHelper(this); txtEmps.setText(txtEmps.getText()+String.valueOf(dbHelper.getEmployeeCount())); Cursor c=dbHelper.getAllDepts();
  • 3. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi startManagingCursor(c); //SimpleCursorAdapterca=new SimpleCursorAdapter(this,android.R.layout.simple_spinner_item,c, new String []{DatabaseHelper.colDeptName},newint[]{android.R.id.text1}); SimpleCursorAdapterca=newSimpleCursorAdapter(this,R.layout.deptspinnerrow,c,newString [] {DatabaseHelper.colDeptName,"_id"},newint[]{R.id.txtDeptName}); //ca.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinDept.setAdapter(ca); spinDept.setOnItemSelectedListener(newOnItemSelectedListener() { publicvoid onItemSelected(AdapterView<?>parent,ViewselectedView, int position,longid) { // TODO Auto-generatedmethodstub } publicvoid onNothingSelected(AdapterView<?>arg0) { // TODO Auto-generatedmethodstub } }); //never close cursor } catch(Exceptionex) { CatchError(ex.toString()); } } publicvoid btnAddEmp_Click(Viewview) {
  • 4. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi booleanok=true; try { Spannable spn=txtAge.getText(); String name=txtName.getText().toString(); int age=Integer.valueOf(spn.toString()); int deptID=Integer.valueOf((int)spinDept.getSelectedItemId()); Employee emp=newEmployee(name,age,deptID); dbHelper.AddEmployee(emp); } catch(Exceptionex) { ok=false; CatchError(ex.toString()); } finally { if(ok) { //NotifyEmpAdded(); Alerts.ShowEmpAddedAlert(this); txtEmps.setText("Numberofemployees"+String.valueOf(dbHelper.getEmployeeCount())); } } } void CatchError(String Exception) { Dialog diag=newDialog(this);
  • 5. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi diag.setTitle("AddnewEmployee"); TextViewtxt=newTextView(this); txt.setText(Exception); diag.setContentView(txt); diag.show(); } void NotifyEmpAdded() { Dialog diag=newDialog(this); diag.setTitle("AddnewEmployee"); TextViewtxt=newTextView(this); txt.setText("Employee AddedSuccessfully"); diag.setContentView(txt); diag.show(); try { diag.wait(1000); } catch (InterruptedExceptione) { // TODO Auto-generatedcatchblock CatchError(e.toString()); } diag.notify(); diag.dismiss(); }} Alerts publicclass Alerts { publicstatic voidShowEmpAddedAlert(Contextcon) {
  • 6. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi AlertDialog.Builderbuilder=newAlertDialog.Builder(con); builder.setTitle("AddnewEmployee"); builder.setIcon(android.R.drawable.ic_dialog_info); DialogListnerlistner=newDialogListner(); builder.setMessage("Employee Addedsuccessfully"); builder.setPositiveButton("ok",listner); AlertDialogdiag=builder.create(); diag.show(); } publicstatic AlertDialogShowEditDialog(final Contextcon,final Employee emp) { AlertDialog.Builderb=newAlertDialog.Builder(con); b.setTitle("Employee Details"); LayoutInflater li=LayoutInflater.from(con); Viewv=li.inflate(R.layout.editdialog,null); b.setIcon(android.R.drawable.ic_input_get); b.setView(v); final TextViewtxtName=(TextView)v.findViewById(R.id.txtDelName); final TextViewtxtAge=(TextView)v.findViewById(R.id.txtDelAge); final Spinnerspin=(Spinner)v.findViewById(R.id.spinDiagDept); Utilities.ManageDeptSpinner(con,spin); for(inti=0;i<spin.getCount();i++) { long id=spin.getItemIdAtPosition(i); if(id==emp.getDept()) { spin.setSelection(i,true);
  • 7. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi break; } } txtName.setText(emp.getName()); txtAge.setText(String.valueOf(emp.getAge())); b.setPositiveButton("Modify",newOnClickListener() { publicvoid onClick(DialogInterface dialog,intwhich) { // TODO Auto-generatedmethodstub emp.setName(txtName.getText().toString()); emp.setAge(Integer.valueOf(txtAge.getText().toString())); emp.setDept((int)spin.getItemIdAtPosition(spin.getSelectedItemPosition())); try { DatabaseHelperdb=new DatabaseHelper(con); db.UpdateEmp(emp); } catch(Exceptionex) { CatchError(con, ex.toString()); } } }); b.setNeutralButton("Delete",new OnClickListener(){ publicvoid onClick(DialogInterface dialog,intwhich) { // TODO Auto-generatedmethodstub DatabaseHelperdb=new DatabaseHelper(con);
  • 8. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi db.DeleteEmp(emp); } }); b.setNegativeButton("Cancel",null); return b.create(); //diag.show(); } static public voidCatchError(Context con, String Exception) { Dialog diag=newDialog(con); diag.setTitle("Error"); TextViewtxt=newTextView(con); txt.setText(Exception); diag.setContentView(txt); diag.show(); } } DatabaseDemo publicclass DatabaseDemo extendsTabActivity { DatabaseHelperdbHelper; GridViewgrid; TextViewtxtTest; /** Calledwhenthe activity is first created.*/ @Override public voidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
  • 9. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi SetupTabs(); } @Override public booleanonCreateOptionsMenu(Menumenu) { menu.add(1,1, 1, "Add Employee"); return true; } public booleanonOptionsItemSelected(MenuItemitem) { switch (item.getItemId()) { //Add employee case 1: Intent addIntent=newIntent(this,AddEmployee.class); startActivity(addIntent); break; } super.onOptionsItemSelected(item); return false; } void SetupTabs() { TabHost host=getTabHost(); TabHost.TabSpec spec=host.newTabSpec("tag1"); Intentin1=new Intent(this,AddEmployee.class); spec.setIndicator("AddEmployee"); spec.setContent(in1);
  • 10. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi TabHost.TabSpec spec2=host.newTabSpec("tag2"); Intentin2=new Intent(this,GridList.class); spec2.setIndicator("Employees"); spec2.setContent(in2); host.addTab(spec); host.addTab(spec2); }} DataBaseHelper publicclass DatabaseHelper extendsSQLiteOpenHelper{ static final String dbName="demoDB"; static final String employeeTable="Employees"; static final String colID="EmployeeID"; static final String colName="EmployeeName"; static final String colAge="Age"; static final String colDept="Dept"; static final String deptTable="Dept"; static final String colDeptID="DeptID"; static final String colDeptName="DeptName"; static final String viewEmps="ViewEmps"; publicDatabaseHelper(Contextcontext) { super(context,dbName,null,33); // TODO Auto-generatedconstructorstub } @Override publicvoid onCreate(SQLiteDatabase db) { // TODO Auto-generatedmethodstub
  • 11. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi db.execSQL("CREATETABLE "+deptTable+" ("+colDeptID+" INTEGER PRIMARY KEY , "+ colDeptName+" TEXT)"); db.execSQL("CREATETABLE "+employeeTable+" ("+colID+" INTEGERPRIMARYKEY AUTOINCREMENT, "+colName+" TEXT, "+colAge+" Integer,"+colDept+" INTEGERNOT NULL ,FOREIGN KEY ("+colDept+") REFERENCES "+deptTable+" ("+colDeptID+"));"); db.execSQL("CREATETRIGGERfk_empdept_deptid" + " BEFORE INSERT "+" ON"+employeeTable+" FOR EACH ROW BEGIN"+" SELECT CASE WHEN ((SELECT "+colDeptID+" FROM "+deptTable+" WHERE "+colDeptID+"=new."+colDept+" ) ISNULL)"+" THEN RAISE (ABORT,'ForeignKeyViolation') END;"+ " END;"); db.execSQL("CREATEVIEW "+viewEmps+" ASSELECT "+employeeTable+"."+colID+" AS_id,"+ " "+employeeTable+"."+colName+","+ " "+employeeTable+"."+colAge+","+" "+deptTable+"."+colDeptName+""+" FROM"+employeeTable+" JOIN"+deptTable+" ON "+employeeTable+"."+colDept+" ="+deptTable+"."+colDeptID ); //Inserts pre-defineddepartments InsertDepts(db); } @Override publicvoid onUpgrade(SQLiteDatabase db,int oldVersion,intnewVersion) { // TODO Auto-generatedmethodstub db.execSQL("DROPTABLE IF EXISTS "+employeeTable); db.execSQL("DROPTABLE IF EXISTS "+deptTable); db.execSQL("DROPTRIGGERIF EXISTS dept_id_trigger"); db.execSQL("DROPTRIGGERIF EXISTS dept_id_trigger22"); db.execSQL("DROPTRIGGERIF EXISTS fk_empdept_deptid"); db.execSQL("DROPVIEW IFEXISTS "+viewEmps); onCreate(db); } void AddEmployee(Employee emp) { SQLiteDatabase db= this.getWritableDatabase();
  • 12. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi ContentValuescv=newContentValues(); cv.put(colName,emp.getName()); cv.put(colAge, emp.getAge()); cv.put(colDept,emp.getDept()); //cv.put(colDept,2); db.insert(employeeTable,colName,cv); db.close(); } int getEmployeeCount() { SQLiteDatabase db=this.getWritableDatabase(); Cursor cur= db.rawQuery("Select*from "+employeeTable,null); int x= cur.getCount(); cur.close(); return x; } Cursor getAllEmployees() { SQLiteDatabase db=this.getWritableDatabase(); //Cursor cur= db.rawQuery("Select"+colID+" as_id , "+colName+","+colAge+" from "+employeeTable,newString[]{}); Cursor cur= db.rawQuery("SELECT * FROM "+viewEmps,null); return cur; } Cursor getAllDepts()
  • 13. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi { SQLiteDatabase db=this.getReadableDatabase(); Cursor cur=db.rawQuery("SELECT "+colDeptID+" as _id, "+colDeptName+" from"+deptTable,new String [] {}); return cur; } void InsertDepts(SQLiteDatabase db) { ContentValuescv=newContentValues(); cv.put(colDeptID,1); cv.put(colDeptName, "Sales"); db.insert(deptTable,colDeptID,cv); cv.put(colDeptID,2); cv.put(colDeptName,"IT"); db.insert(deptTable,colDeptID,cv); cv.put(colDeptID,3); cv.put(colDeptName,"HR"); db.insert(deptTable,colDeptID,cv); db.insert(deptTable,colDeptID,cv); } publicString GetDept(intID) { SQLiteDatabase db=this.getReadableDatabase(); String[]params=new String[]{String.valueOf(ID)}; Cursor c=db.rawQuery("SELECT "+colDeptName+" FROM"+deptTable+" WHERE "+colDeptID+"=?",params); c.moveToFirst();
  • 14. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi int index=c.getColumnIndex(colDeptName); return c.getString(index); } publicCursor getEmpByDept(StringDept) { SQLiteDatabase db=this.getReadableDatabase(); String [] columns=newString[]{"_id",colName,colAge,colDeptName}; Cursor c=db.query(viewEmps,columns,colDeptName+"=?",newString[]{Dept},null, null,null); return c; } public intGetDeptID(StringDept) { SQLiteDatabase db=this.getReadableDatabase(); Cursor c=db.query(deptTable,newString[]{colDeptID+" as _id",colDeptName},colDeptName+"=?", new String[]{Dept},null,null,null); //Cursor c=db.rawQuery("SELECT "+colDeptID+" as _id FROM "+deptTable+" WHERE "+colDeptName+"=?",newString[]{Dept}); c.moveToFirst(); return c.getInt(c.getColumnIndex("_id")); } publicint UpdateEmp(Employee emp) { SQLiteDatabase db=this.getWritableDatabase(); ContentValuescv=newContentValues(); cv.put(colName,emp.getName()); cv.put(colAge,emp.getAge()); cv.put(colDept,emp.getDept()); return db.update(employeeTable,cv,colID+"=?",newString []{String.valueOf(emp.getID())});
  • 15. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi } publicvoid DeleteEmp(Employee emp) { SQLiteDatabase db=this.getWritableDatabase(); db.delete(employeeTable,colID+"=?",newString[]{String.valueOf(emp.getID())}); db.close();}} DialogListener publicclass DialogListnerimplementsandroid.content.DialogInterface.OnClickListener{ publicDialogListner() { } publicvoid onClick(DialogInterface dialog,intwhich) { // TODO Auto-generatedmethodstub } } Employee publicclass Employee { int _id; String _name; int _age; int _dept; publicEmployee(StringName,intAge,intDept) { this._name=Name; this._age=Age; this._dept=Dept;
  • 16. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi } publicEmployee(StringName,intAge) { this._name=Name; this._age=Age; } publicint getID() { return this._id; } publicvoid SetID(intID) { this._id=ID; } publicString getName() { return this._name; } publicint getAge() { return this._age; } publicvoid setName(StringName) { this._name=Name; } publicvoid setAge(intAge) {
  • 17. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi this._age=Age; } publicvoid setDept(intDept) { this._dept=Dept; } publicString getDeptName(Contextcon,intDept) { return newDatabaseHelper(con).GetDept(Dept); } publicint getDept() { return this._dept; } } GridList publicclass GridListextendsActivity { DatabaseHelperdbHelper; static public GridViewgrid; TextViewtxtTest; SpinnerspinDept1; /** Calledwhenthe activity is first created.*/ @Override public voidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gridview); grid=(GridView)findViewById(R.id.grid);
  • 18. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi txtTest=(TextView)findViewById(R.id.txtTest); spinDept1=(Spinner)findViewById(R.id.spinDept1); Utilities.ManageDeptSpinner(this.getParent(),spinDept1); final DatabaseHelperdb=new DatabaseHelper(this); try { spinDept1.setOnItemSelectedListener(newOnItemSelectedListener() { publicvoid onItemSelected(AdapterView<?>arg0,Viewarg1, int arg2, longarg3) { // TODO Auto-generatedmethodstub LoadGrid(); //sca.notifyDataSetChanged(); } publicvoid onNothingSelected(AdapterView<?>arg0) { // TODO Auto-generatedmethodstub } }); } catch(Exceptionex) { txtTest.setText(ex.toString()); } try { grid.setOnItemClickListener(newOnItemClickListener() { publicvoid onItemClick(AdapterView<?>parent,Viewv,int position,
  • 19. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi long id) { // TODO Auto-generatedmethodstub try { SQLiteCursorcr=(SQLiteCursor)parent.getItemAtPosition(position); String name= cr.getString(cr.getColumnIndex(DatabaseHelper.colName)); int age=cr.getInt(cr.getColumnIndex(DatabaseHelper.colAge)); String Dept= cr.getString(cr.getColumnIndex(DatabaseHelper.colDeptName)); Employee emp=newEmployee(name,age,db.GetDeptID(Dept)); emp.SetID((int)id); AlertDialogdiag= Alerts.ShowEditDialog(GridList.this,emp); diag.setOnDismissListener(newOnDismissListener() { publicvoid onDismiss(DialogInterface dialog) { // TODO Auto-generatedmethodstub txtTest.setText("dismissed"); //((SimpleCursorAdapter)grid.getAdapter()).notifyDataSetChanged(); LoadGrid(); } }); diag.show(); } catch(Exceptionex) { Alerts.CatchError(GridList.this,ex.toString()); } }
  • 20. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi }); } catch(Exceptionex) { } } @Override public voidonStart() { super.onStart(); //LoadGrid(); } public voidLoadGrid() { dbHelper=newDatabaseHelper(this); try { //Cursor c=dbHelper.getAllEmployees(); Viewv=spinDept1.getSelectedView(); TextViewtxt=(TextView)v.findViewById(R.id.txtDeptName); String Dept=String.valueOf(txt.getText()); Cursor c=dbHelper.getEmpByDept(Dept); startManagingCursor(c); String [] from=newString []{DatabaseHelper.colName,DatabaseHelper.colAge,DatabaseHelper.colDeptName}; int [] to=new int[] {R.id.colName,R.id.colAge,R.id.colDept}; SimpleCursorAdaptersca=newSimpleCursorAdapter(this,R.layout.gridrow,c,from,to);
  • 21. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi grid.setAdapter(sca); } catch(Exceptionex) { AlertDialog.Builderb=newAlertDialog.Builder(this); b.setMessage(ex.toString()); b.show(); } } } Utilities publicclass Utilities{ static public voidManageDeptSpinner(Contextcontext,Spinnerview) { DatabaseHelperdbHelper=newDatabaseHelper(context); Cursor c=dbHelper.getAllDepts(); //context.startManagingCursor(c); //SimpleCursorAdapterca=new SimpleCursorAdapter(this,android.R.layout.simple_spinner_item,c,new String [] {DatabaseHelper.colDeptName},newint[]{android.R.id.text1}); SimpleCursorAdapterca=newSimpleCursorAdapter(context,R.layout.deptspinnerrow,c,newString [] {DatabaseHelper.colDeptName,"_id"},newint[]{R.id.txtDeptName}); view.setAdapter(ca); } }
  • 22. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi XML AddEmployee <?xml version="1.0" encoding="utf-8" ?> - <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height ="wrap_content"> - <LinearLayout android:layout_width="fill_parent" android:layout_height ="wrap_content" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height ="wrap_content" android:text="Employee Name" /> <EditText android:layout_width="fill_parent" android:layout_height ="fill_parent" android:id="@+id/txtName" android:autoText="false" /> <TextView android:layout_width="wrap_content" android:layout_height ="wrap_content" android:text="Employee Age" /> <EditText android:layout_width="fill_parent" android:layout_height ="fill_parent" android:id="@+id/txtAge" android:inputType="number" android:digits="0123456789" android:singleLine="true" /> <TextView android:layout_width="wrap_content" android:layout_height ="wrap_content" android:text="Employee Dept" /> <Spinner android:layout_width="fill_parent" android:layout_height ="fill_parent" android:id="@+id/spinDept" /> <Button android:layout_width="wrap_content" android:layout_height ="wrap_content" android:id="@+id/btnAdd" android:text="Add Employee" android:onClick="btnAddEmp_Click" /> <TextView android:layout_width="wrap_content" android:layout_height ="wrap_content" android:text="Number of employees" android:id="@+id/txtEmps" /> </LinearLayout > </ScrollView> editdialog <?xml version="1.0" encoding="utf-8" ?> - <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height ="wrap_content" android:orientation="vertical"> - <TableRow> <TextView android:layout_width="fill_parent" android:layout_height ="wrap_content" android:text="Name:" /> <EditText android:layout_width="fill_parent" android:layout_height ="wrap_content" android:id="@+id/txtDelName" /> </TableRow> - <TableRow> <TextView android:layout_width="fill_parent" android:layout_height ="wrap_content" android:text="Age:" /> <EditText android:layout_width="fill_parent" android:layout_height ="wrap_content" android:id="@+id/txtDelAge" /> </TableRow> - <TableRow> <Spinner android:layout_width="fill_parent" android:layout_height ="wrap_content" android:id="@+id/spinDiagDept" android:layout_span="2" /> </TableRow> <TableRow /> </TableLayout>
  • 23. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi Deptspinnerrow <?xml version="1.0" encoding="utf-8" ?> - <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height ="wrap_content"> <TextView android:layout_width="fill_parent" android:layout_height ="wrap_content" android:id="@+id/txtDeptName" android:textColor="#000" /> <TextView android:layout_width="fill_parent" android:layout_height ="wrap_content" android:id="@+id/txtDeptID" android:textColor="#000" /> </LinearLayout > Gridrow <?xml version="1.0" encoding="utf-8" ?> - <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> - <TableRow> <TextView android:layout_width="50px" android:layout_height ="wrap_content" android:id="@+id/colName" android:padding="5px" android:layout_weight ="1" /> <TextView android:layout_width="50px" android:layout_height ="wrap_content" android:id="@+id/colAge" android:padding="5px" android:layout_weight="1" /> <TextView android:layout_width="50px" android:layout_height ="wrap_content" android:id="@+id/colDept" android:padding="5px" android:layout_weight ="1" /> </TableRow> </TableLayout> Gridview <?xml version="1.0" encoding="utf-8" ?> - <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height ="wrap_content" android:id="@+id/tab1"> - <TableLayout android:layout_width="fill_parent" android:layout_height ="fill_parent"> - <TableRow> <Spinner android:layout_width="fill_parent" android:layout_height ="fill_parent" android:id="@+id/spinDept1" android:layout_span="3" /> </TableRow> - <TableRow> <TextView android:layout_width="fill_parent" android:layout_height ="fill_parent" android:text="Employee Name" android:layout_weight ="1" /> <TextView android:layout_width="fill_parent" android:layout_height ="fill_parent" android:text="Employee Age" android:layout_weight="1" /> <TextView android:layout_width="fill_parent" android:layout_height ="fill_parent" android:text="Department" android:layout_weight ="1" /> </TableRow> </TableLayout> <GridView android:id="@+id/grid" android:layout_width="fill_parent" android:layout_height ="fill_parent" android:numColumns="1" android:stretchMode="columnWidth" /> <TextView android:layout_width="fill_parent" android:layout_height ="fill_parent" android:text="Employee Age" android:id="@+id/txtTest" /> </LinearLayout >
  • 24. A7, StephanosTower,Eachamukku,Kakkanadu,Kochi listview <?xml version="1.0" encoding="utf-8" ?> - <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height ="wrap_content"> <ListView android:id="@+id/listEmps" android:layout_width="fill_parent" android:layout_height ="fill_parent" android:text="A semi-random button" /> <TextView android:layout_width="fill_parent" android:layout_height ="wrap_content" android:text="@string/hello" android:id="@+id/txt" /> </LinearLayout > Main <?xml version="1.0" encoding="utf-8" ?> - <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height ="fill_parent" android:id="@android:id/tabhost"> <TabWidget android:layout_width="fill_parent" android:layout_height ="wrap_content" android:id="@android:id/tabs" /> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height ="fill_parent" android:paddingTop="60px" /> </TabHost>