Headline

Advanced Technology:Android programming

Motivation

The implementation demonstrates advanced style of Technology:Android programming using the Technology:Android SDK and the Technology:Android Development Tool. It is based on simpleAndroid with more features and functionalities. The application is in the position to explore and edit the company structure. The feature Feature:Closed serialization can save and load company objects. The total and cut features are also implemented. The application demonstarates more listener like the onLongClickListener. This implementation shows how to use defferent dialogs and how to use options menu. Also there are more views like the edit text. The feature Feature:Localization is also implemented. If you change your system language then the application language will also change.

Illustration

Dialogs

AlertDialog

Builder build = new Builder(DepartmentClickActivity.this);
	build.setTitle(R.string.areyousure)
	.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
		@Override
		public void onClick(DialogInterface dialog, int which) {
		...
	})
	.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
		@Override
		public void onClick(DialogInterface dialog, int which) {
			dialog.dismiss();
		}
	})
	.show();

An alert dialog is generated with a builder. In line two we set the title of the dialog and in the next lines we set two buttons with their on click listener. In the last line we show the Dialog in front of the active activity.

Custom Dialog

Dialog dialog = new Dialog(this);
dialog.setTitle(R.string.createtheemployee);
dialog.setContentView(R.layout.newemployee);
((Button)dialog.findViewById(R.id.bt Cancel newemployee)).setOnClickListener(new OnClickListener() {
	@Override
	public void onClick(View arg0) {
		dialog.dismiss();
	}
});				
dialog.show();

In a custom Dialog we put a view in line three, which we have created in the resources as XML layout. In the last line we show the dialog in front of the active activity.

Options Menu

Create Menu

@Override
public boolean onCreateOptionsMenu(Menu menu) {
	getMenuInflater().inflate(R.menu.menue, menu);
	menu.getItem(1).setTitle(R.string.addEmployee);
	menu.getItem(0).setTitle(R.string.addDepartment);
	return super.onCreateOptionsMenu(menu);
}

If we click on the options button of our Smartphone then the onCreateOptionsMenu method will be started. In line three we put the created menu layout with the menu inflater. In line four and five we edit the entries of the Menu.

Give functionality

@Override
public boolean onOptionsItemSelected(MenuItem item) {
	switch (item.getItemId()) {
		case R.id.opt total:{
			Toast.makeText(this, dept.total()+"", Toast.LENGTH SHORT).show();
			return true;
		}
		case R.id.opt cut:{
			dept.cut();
			Toast.makeText(this,R.string.successful, Toast.LENGTH SHORT).show();
			return true;
		}
		...
	}
	return false;
}

With the method onOptionsItemSelected we give the elements of the menu a funtionality.

Edittext

EditText ed name = ((EditText)findViewById(R.id.ed name));
...
ed name.setText(employee.getName());
...
((EditText)findViewById(R.id.ed name)).getText().toString().trim();

With an EditText we can edit the data of an Employee, the name of a Department and the name of the Company. In line three we put a String for example the employee's name, address or salary. After changing the String or after an action of the user we get the String from the edit text in line five.

Architecture

Usage

Metadata


There are no revisions for this page.

User contributions

    This user never has never made submissions.

    User edits

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.