Android development framework is relatively easier.The development is realy faster here.
Problem here is that developing UI and it's layouts are a bit painful and it really consume most of our efforts. For GUI we
- Write xml by hand, very tedious and time consuming even with good text editor
- Use Eclipse and android plugin's layout editor. Very cumbersome, crappy user interface on the editor.
What I feel is is that development of GUI for Android should be done by UI expert specific to android specially layout xml from some tools.
DroidDraw actually is currently the best tool for UI that can be used to build GUIs for Android.
Android Application :
Android application package file (APK) is the file format used to distribute and install application software and middleware onto Android operating system.
Here we are going to look through samples for some common requirements.
How to configure the development set-up:
• Install SDK starter package http://developer.android.com/sdk/index.html
• Download ADT plug-in from the repository : https://dl-ssl.google.com/android/eclipse/
• Configure ADT plug-in:: eclipse >window>preferences> links to SDK to downloaded SDK directory.
• Installing available packages for SDK
Eclipse, >Window > Android SDK and AVD Manager>Download at least one Platform SDK (>2.2)
How to set-up layout view:
setContentView(R.layout.YourApplicationLayout1.xml);
setContentView(R.layout.main);
How to set access View componnets :
Button buttonView = (Button) findViewById(R.id.viewButton);
inputValue = (EditText) findViewById(R.id.inputText);
How to call activity on Button Press:
Button postBtn = (Button) findViewById(R.id.button1);
moodMessageText = (EditText) findViewById(R.id.moodMessageText);
mDate = (TextView) findViewById(R.id.datefield);
postBtn.setOnClickListener(new OnClickListener() {
public void onClick(View arg0);
//start calling activities
}
}
});
How to call Multiple Activities on some event:
It's so simple:
public class SourceActivity extends Activity {
startActivity1(intent);
startActivity2(arg0);
}
How to pass parameters across Activities:
Using Intent.
Intent intent = new Intent(SourceActivity.this,DestinationActivity.class);
Bundle b = new Bundle();
b.putString("paramater1", parameter1Value);
intent.putExtras(b);
startActivity(intent);:
public class DestinationActivity extends Activity {
Bundle b = getIntent().getExtras();
String moodMessageTextVal = b.getString("moodMessageText");
String dateVal = b.getString("date");
How to create List View:
<?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="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_notes"/>
</LinearLayout>
How to show message pops up on the surface of the window:
Toast toast = Toast.makeText(getApplicationContext(), yourMessages, duration);
toast.setGravity(Gravity.TOP|Gravity.LEFT, 0, 0);
How to configure the development set-up:
• Install SDK starter package http://developer.android.com/sdk/index.html
• Download ADT plug-in from the repository : https://dl-ssl.google.com/android/eclipse/
• Configure ADT plug-in:: eclipse >window>preferences> links to SDK to downloaded SDK directory.
• Installing available packages for SDK
Eclipse, >Window > Android SDK and AVD Manager>Download at least one Platform SDK (>2.2)
How to set-up layout view:
setContentView(R.layout.YourApplicationLayout1.xml);
setContentView(R.layout.main);
How to set access View componnets :
Button buttonView = (Button) findViewById(R.id.viewButton);
inputValue = (EditText) findViewById(R.id.inputText);
How to call activity on Button Press:
Button postBtn = (Button) findViewById(R.id.button1);
moodMessageText = (EditText) findViewById(R.id.moodMessageText);
mDate = (TextView) findViewById(R.id.datefield);
postBtn.setOnClickListener(new OnClickListener() {
public void onClick(View arg0);
//start calling activities
}
}
});
How to call Multiple Activities on some event:
It's so simple:
public class SourceActivity extends Activity {
startActivity1(intent);
startActivity2(arg0);
}
How to pass parameters across Activities:
Using Intent.
Intent intent = new Intent(SourceActivity.this,DestinationActivity.class);
Bundle b = new Bundle();
b.putString("paramater1", parameter1Value);
intent.putExtras(b);
startActivity(intent);:
public class DestinationActivity extends Activity {
Bundle b = getIntent().getExtras();
String moodMessageTextVal = b.getString("moodMessageText");
String dateVal = b.getString("date");
How to create List View:
<?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="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_notes"/>
</LinearLayout>
How to show message pops up on the surface of the window:
Toast toast = Toast.makeText(getApplicationContext(), yourMessages, duration);
toast.setGravity(Gravity.TOP|Gravity.LEFT, 0, 0);
How to populate List View from SQLite DB:
public class RenderListViewActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.RenderListViewPage);
DBHelper dbHelper = new DBHelper(this);
Cursor c = dbHelper.getAllListRecords();
fillListViewData(c);
}
private void fillListViewData(Cursor c) {
startManagingCursor(c);
String[] from = new String[] { "headerCol1","headerCol2", "headerCol3"};
int[] to = new int[] { R.id.headerCol1,R.id.headerCol2,R.id.headerCol3 };
SimpleCursorAdapter listBeanData =
new SimpleCursorAdapter(this, R.layout.listitem, c, from, to);
setListAdapter(listBeanData);
}
How to open a URL in Webview:
layout configuration
<WebView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/myWebview"/>"
code:
WebView webview = (WebView)findViewById(R.id.myWebview);
webview.getSettings().setJavaScriptEnabled(true);
webview.setInitialScale(100);
webview.setWebViewClient(new WebViewClient()
webview.loadUrl(yourWebUrl);
How to show process dialog:
ProgressDialog progressdialog = ProgressDialog.show(this, "",
"Loading. Please wait...", true);
webview.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
if (progressdialog.isShowing()) {
progressdialog.dismiss();
}
}
});
public class RenderListViewActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.RenderListViewPage);
DBHelper dbHelper = new DBHelper(this);
Cursor c = dbHelper.getAllListRecords();
fillListViewData(c);
}
private void fillListViewData(Cursor c) {
startManagingCursor(c);
String[] from = new String[] { "headerCol1","headerCol2", "headerCol3"};
int[] to = new int[] { R.id.headerCol1,R.id.headerCol2,R.id.headerCol3 };
SimpleCursorAdapter listBeanData =
new SimpleCursorAdapter(this, R.layout.listitem, c, from, to);
setListAdapter(listBeanData);
}
How to open a URL in Webview:
layout configuration
<WebView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/myWebview"/>"
code:
WebView webview = (WebView)findViewById(R.id.myWebview);
webview.getSettings().setJavaScriptEnabled(true);
webview.setInitialScale(100);
webview.setWebViewClient(new WebViewClient()
webview.loadUrl(yourWebUrl);
How to show process dialog:
ProgressDialog progressdialog = ProgressDialog.show(this, "",
"Loading. Please wait...", true);
webview.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
if (progressdialog.isShowing()) {
progressdialog.dismiss();
}
}
});
Emulator:
The Android SDK includes a mobile device emulator — a virtual mobile device
that runs on your computer. which can be used for developing and testing
Android applications without using a physical device.
Android Pencil utility tool is available here android-ui-utils .
Google has started a project called App Inventor to give non-programmers a relatively easy way to build their own applications for the Android.
I feel that Android UI tools always have a BIG BIG scope of improvement. Otherwise It would be really difficult for Android to chase with IPhone.
How is your experience with Android?