Softech Systems International -SSI

Softech Systems International -SSI This is a Software company, we Design all Softwares for all platforms, we develop Android Apps, Build and Design Websites, Databases. Come and Experience.

21/11/2015

We have opportunities for people talented in IT come and we assist you in improving your IT skills by working with us. Send message if interested on [email protected]

24/10/2015

Hallo guys..... Visit our new website and read more about our products. And our products are very cheap and durable.

07/09/2015

Come and see what we have for you our estemeed customers

Number System Converter Android AppIntroductionAndroid is an exciting platform for developing apps that run on a mobile ...
25/08/2015

Number System Converter Android App
Introduction

Android is an exciting platform for developing apps that run on a mobile device. Any programmer familiar with Java can learn Android quickly and start developing Android apps. The class library of Android is a subset of Java SE. The two main elements of Android are the Android SDK and an Eclipse plug-in called 'The Android Development Tools (ADT)'. You must ensure the appropriate installation of the SDK and ADT before starting development.

In this article, I am describing how to create an Android app to perform conversion of a decimal number to binary, octal and hexadecimal formats.
Background

There are four building blocks of any android application:

Activities: The basic building block of a user interface in Android is an activity. An activity represents the main screen with which a user can interact with an application.
Content Providers: Content providers provide abstraction for data required by multiple applications.
Intents: Intents are system messages, for e.g., event notifications, for e.g., hardware changes (like SD card insertion), incoming data (like SMS), etc.
Services: Services are independent activities not having an interface for e.g., music playback.

Activities are public classes derived from the android.app.Activity base class. The following code represents an activity in the application:
Hide Copy Code

public class MyActivity extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
}
}

The onCreate() method gets invoked when the activity is started. The first statement in this method must be to invoke the base classes' onCreate() method to initialize the Android activity.

User interfaces in Android can be created either through Java code or XML files. Using XML files for creating user interfaces is highly preferred because it provides separation of the user interface code from the business logic code.

Following is an example of a LinearLayout definition.
Hide Copy Code





Every android project has an auto-generated R.java file. This file is used to refer to resources in your project. For e.g., if the main.xml layout file defines the following resource:
Hide Copy Code



then it can be used in the activity class by writing the following code:
Hide Copy Code

Button btn=(Button)findViewById(R.id.button1);

Events in android are handled in the same way as in Java SE. For e.g., an activity class can implement the View.onClickListener interface, having the onClick() method to handle the click event of a button. Similarly, the TextWatcher interface can be used to handle the text changed event in an EditText control. The TextWatcher interface has three methods, beforeTextChanged(), afterTextChanged(), and onTextChanged().

User Interface components in Android are represented by Views. The View class is the base class of all components. Some of the views are TextView, EditText, Button, RadioButton and Checkbox. View can respond to events using listeners. Assigning listeners to Views is done in the same way as in Java 2 SE.

For e.g., the following code sets the listener for a Button to respond to the click event:
Hide Copy Code

button1.setOnClickListener(this);

The following code sets the listener for an EditText to respond to the text changed event:
Hide Copy Code

txtDecimal.addTextChangedListener(this);

Dialog boxes are created in android using the Builder class. The Builder class has the following methods:

setTitle(): To set title for the dialog
setMessage(): To set message for the dialog
setCancelable(): To allow/disallow cancelling the dialog
show(): To display the dialog

The following code can be used to create a dialog box and display it.
Hide Copy Code

Builder builder=new Builder(this);
builder.setCancelable(true);
builder.setTitle("Title");
builder.setMessage("Message");
builder.show();

Using the code

In my application, I have created an EditText control having id txtDecimal to accept a number in decimal format and three TextView controls having IDs txtBinary, txtOctal and txtHexadecimal to display the numbers in binary, octal and hexadecimal formats.

Following is the complete code of the main.xml layout file:
Hide Copy Code














Following is the code of the main activity:
Hide Shrink Copy Code

package com.azim;

import java.util.Stack;
import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.view.View;
import android.text.Editable;
import android.text.TextWatcher;

public class MyActivity extends Activity implements TextWatcher,View.OnClickListener
{
EditText txtDecimal;
TextView txtBinary,txtOctal,txtHexadecimal;
Button btnAbout;

/** Called when the activity is first created. */

public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
txtDecimal=(EditText)findViewById(R.id.txtDecimal);
txtBinary=(TextView)findViewById(R.id.txtBinary);
txtOctal=(TextView)findViewById(R.id.txtOctal);
txtHexadecimal=(TextView)findViewById(R.id.txtHexadecimal);
txtDecimal.addTextChangedListener(this);
btnAbout=(Button)findViewById(R.id.button1);
btnAbout.setOnClickListener(this);
}
public void beforeTextChanged(CharSequence sequence,int start,int count,int after)
{
}
public void afterTextChanged(Editable editable)
{
}
public void onTextChanged(CharSequence sequence,int start,int before,int count)
{
calculate(2,txtBinary); // for base 2 (binary)
calculate(8,txtOctal); // for base 8 (octal)
calculate(16,txtHexadecimal); // for base 16 (hexadecimal)
}
public void calculate(int base,TextView txtView)
{
if(txtDecimal.getText().toString().trim().length()==0)
{
txtView.setText("");
return;
}
try
{
Stack stack=new Stack();
int number=Integer.parseInt(txtDecimal.getText().toString());
while (number>0)
{
int remainder=number%base; // find remainder
if(remainder

18/07/2015

We Develop websites and Other softwares

06/07/2015

If you have any school that needs a School Management System we have it. At an affordable price

06/07/2015

Cheap it products

06/07/2015

IT is only for people who can think strongly beyond the obvious, say Amen if u are

28/02/2015

If You are in the IT sector and you can't write a single line of Code, with no errors. Then you are in a wrong place. IT nolonger needs Designers it needs people who know what is happening behind the Scenes....
Thank You all of those Who have put in their time to learn the Code.

22/02/2015

Post a Product of your choice that you would us to Develop for you. And it will be at Your Desk in the Shortest time Possible...
E.g
Java Based Applications
Android Apps
Websites
Networking

03/01/2015

We have Vacant Posts as Follows.
1. Marketing Manager (2)
2. Accountant (1)
3. Website Developer(3)
4. Graphics Designer(2)
5. Project Researcher (2)

Requirements:-
1. U must have Passion of What u are Doin.
2. Be computer literate.

Note:
We don't look at how many papers you have. What we look at is What can you do....m

Get an Iphone 4S at only 500,000/= from us, contact us Before they are done, only 4 left in stock. Hurry!! Be the FirstC...
22/12/2014

Get an Iphone 4S at only 500,000/= from us, contact us Before they are done, only 4 left in stock. Hurry!! Be the First
Contact Us through
Tel: 0751481314

Address

Kampala
256

Alerts

Be the first to know and let us send you an email when Softech Systems International -SSI posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Share