tag:blogger.com,1999:blog-91767203250127872902024-03-27T16:53:30.121-07:00Android Development HelperThis blog is created to help you in Android Development.This will be helpful to Beginners as well as Experiencing Developers. For easy understanding screen shots and graphics are widely used.To further help you, links to useful Android resources and an Exclusive search in best Android forums is given. In contrast to other Android sites many shortcuts and very useful tips are also given. You may post your feedback, syntax, tips and shortcuts as comments.Arise Rayamangalamhttp://www.blogger.com/profile/17522192478676631711noreply@blogger.comBlogger14125tag:blogger.com,1999:blog-9176720325012787290.post-63659712586028747402013-03-21T14:30:00.000-07:002015-05-11T09:23:47.567-07:001. How to download and Install Android Development Platform SDK<div dir="ltr" style="text-align: left;" trbidi="on">
Android is an open source operating system for smart phones which is running on a Linux Kernel. Java is the language used for developing android platform and applications. Since it is open source there are plenty of free training,development help and free sample codes available in the net. As you know the Android phones are making revolutions in the mobile phone market. Android gives you an exciting, free platform to make useful applications for the different branded Android phones available in the market and you may also make money from it. If you are new to the Android development and Java the best thing is to know the basic of XML and Java before starting development in Android. Interesting thing is that you can start developing in Android even if you don't have any knowledge in software development. Everything is available in the net.<br />
<br />
You may First download the <a href="http://adf.ly/1GxUV7" target="_blank">Android Software Development Kit (SDK)</a> (choose skip add in the next screen) from here or the link given in the side bar. <span style="background-color: lime; color: black;">(TIP)</span> Since it is 398MB don't directly download using Chrome or Forefox because if your connection is interrupted the download will be automatically cancelled and you will have to download it again. Best thing is to use <a href="http://adf.ly/Kmmul" target="_blank">Internet Download Accelerator (Click here)</a>. It will download much faster as it will make many connections to the download site. You can also pause it and resume it on the next day.<br />
(See the image below)<br />
Go the <span style="background-color: yellow;">Android </span>site by <a href="http://developer.android.com/sdk/index.html" target="_blank">clicking the link</a> and <span style="background-color: yellow;">click on the download</span> link as shown below. <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-yYT824cKsyc/UPJf4rchWPI/AAAAAAAAAYM/MqYEmCqlWww/s1600/screen20.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="374" src="http://4.bp.blogspot.com/-yYT824cKsyc/UPJf4rchWPI/AAAAAAAAAYM/MqYEmCqlWww/s640/screen20.png" width="640" /></a></div>
<br />
Now <span style="background-color: yellow;">click to agree</span> to the terms and conditions, <span style="background-color: yellow;">select 32bit or 64 bit</span>, if you don't know your system is 32 or 64 bit then follow the instruction down below to check it.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-G6DUgN0DXsY/UPJh5uu0uJI/AAAAAAAAAYc/M6vi93gs6-8/s1600/screen21.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="372" src="http://3.bp.blogspot.com/-G6DUgN0DXsY/UPJh5uu0uJI/AAAAAAAAAYc/M6vi93gs6-8/s640/screen21.png" width="640" /></a></div>
<br />
<span style="background-color: lime;">(TIP)</span> If you <span style="background-color: yellow;">don't know </span>your system is <span style="background-color: yellow;">32 bit or 64 bit</span>, then <span style="background-color: yellow;">Right click </span>on the icon named <span style="background-color: yellow;">"Computer" </span>and click "<span style="background-color: yellow;">properties</span>" Now a window named "basic information about your computer is opened, The <span style="background-color: yellow;">system types</span> specifies it is 32 bit or 64 bit. (see the image below for details)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-yjgok47h838/UPJlEY7jFBI/AAAAAAAAAYs/DYbWG4CC4Sc/s1600/screen22.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="374" src="http://4.bp.blogspot.com/-yjgok47h838/UPJlEY7jFBI/AAAAAAAAAYs/DYbWG4CC4Sc/s640/screen22.png" width="640" /></a></div>
<br />
Now click download and<span style="background-color: yellow;"> Download</span> will <span style="background-color: yellow;">automatically</span> started. If you use Internet Download Accelerator,<br />
it will automatically detect the link and start downloading. IF not clcik the green plus button on the tool bar and copy,paste the download link and click "start download". (see the image for detials)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-7vRN6yN0EiQ/UPJmtc452UI/AAAAAAAAAY8/Yfrf_9SJ-Rs/s1600/screen23.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="374" src="http://1.bp.blogspot.com/-7vRN6yN0EiQ/UPJmtc452UI/AAAAAAAAAY8/Yfrf_9SJ-Rs/s640/screen23.png" width="640" /></a></div>
<br />
When your <span style="background-color: yellow;">download completes</span> go the folder where the file is downloaded and clcik the zip file named<br />
<span style="background-color: yellow;">"android adt...."</span> to open it in Winzip. (as shown below)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-_peLovX0i4M/UPJn-altU9I/AAAAAAAAAZM/-ltLA-cdF7o/s1600/screen24.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="374" src="http://4.bp.blogspot.com/-_peLovX0i4M/UPJn-altU9I/AAAAAAAAAZM/-ltLA-cdF7o/s640/screen24.png" width="640" /></a></div>
Now the files will be opened in Winzip, select all files by clicking<span style="background-color: yellow;"> Ctrl+A</span> and <span style="background-color: yellow;">click extract</span> from the toolbar above. Choose a location to extract, better create a new folder named "android". Be sure that the <span style="background-color: yellow;">"use folder name"</span> is checked otherwise check it.<span style="background-color: lime;">(TIP)</span> If not, it will not make any inner folders required to run Eclipse. (see image for details)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-TVRhJwOZtYc/UPJptU8P1OI/AAAAAAAAAZc/3W4rNnHzrLE/s1600/screen25.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="374" src="http://2.bp.blogspot.com/-TVRhJwOZtYc/UPJptU8P1OI/AAAAAAAAAZc/3W4rNnHzrLE/s640/screen25.png" width="640" /></a></div>
<br />
Now all the files will be extracted and the folder window is automatically opened (as shown below). Now double click on the folder named<span style="background-color: yellow;"> "adt-bundle..."</span> to open it.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-PPJn1B7gx5w/UPJqSr2tcpI/AAAAAAAAAZk/HwJrg4u617Y/s1600/screen26.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="374" src="http://4.bp.blogspot.com/-PPJn1B7gx5w/UPJqSr2tcpI/AAAAAAAAAZk/HwJrg4u617Y/s640/screen26.png" width="640" /></a></div>
<br />
Now you can see a folder named<span style="background-color: yellow;"> "eclipse"</span> click to open it. (as shown below) <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-AxNKX1XCovc/UPJqvOk8yOI/AAAAAAAAAZs/4YdepbHY5LE/s1600/screen27.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="374" src="http://2.bp.blogspot.com/-AxNKX1XCovc/UPJqvOk8yOI/AAAAAAAAAZs/4YdepbHY5LE/s640/screen27.png" width="640" /></a></div>
<br />
Inside the folder you can see a file named <span style="background-color: yellow;">"eclipse.exe"</span> click on the icon to <span style="background-color: yellow;">launch Eclipse</span>. Note that android uses Eclipse, an open source platform with ADT
(Android Development Tools) plugin to develop Android applications. <span style="background-color: lime;">(TIP)</span> Please note that there is no need to install it in Windows. That's why the exe file is directly available. <span style="background-color: lime;">(TIP)</span> Just right click on the file and <span style="background-color: yellow;">make a shortcut to the desktop</span> so that
you can launch it easily next time. You don't have to worry about other
files and folders as everything will be accessible from Eclipse. <br />
<br />
The Android Developer site will also give you all the directions for downloading and running the SDK. You may also download it for Linux,Windows and Mac. Now you have successfully completed the first step in Android Development. We will discus the other topics in the next chapter. Mean while just go through the resources links on the right side to learn about Android Development. If you are new to Jave read this PDF <a href="http://adf.ly/LYBRb" target="_blank">Learn Java For Android</a><br />
<span style="background-color: lime;">(TIP)</span> If you read pages from 43 to 82 you will get a basic idea.<br />
<br />
<span style="background-color: lime;">(TIP)</span> Eventhough I have explained it for Windows, I strongly suggest you to use Ubuntu Linux for Android Development, as the emulator is slow, always crashing and not responding in Windows. Unlike Windows, Ubuntu is a cute,very fast,quick booting and easy to use OS with 1000's of free softwares. In Ubuntu ADT is very fast and stable. Setting up ADT bundle in Ubuntu is as easy as in Windows. You may <a href="http://adf.ly/KtNOC" target="_blank">Download Ubuntu free from here </a>(750MB)<br />
<br />
<br />
<br />
Now you can move to the<b> <a href="http://android-helper4u.blogspot.in/2013/01/how-to-work-in-android-sdk-eclipse.html" target="_blank">NEXT CHAPTER </a></b></div>
Arise Rayamangalamhttp://www.blogger.com/profile/17522192478676631711noreply@blogger.com696tag:blogger.com,1999:blog-9176720325012787290.post-27788373622004623022013-03-21T01:23:00.004-07:002013-03-21T01:24:25.481-07:00e. How to give a zoomable picture in an ApplicationZoomable pictures are only supported in Webview and Mapview. So first we have to create a Webview layout with zoom controls in it.<br />
First <span style="background-color: yellow;">copy the picture</span> in to the <span style="background-color: yellow;">assets</span> folder <br />
Then, Copy the following code in to <span style="background-color: yellow;">activity_main.xml</span> file<br />
<br />
<span style="color: blue;"><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"<br /> xmlns:tools="http://schemas.android.com/tools"<br /> android:layout_width="match_parent"<br /> android:layout_height="match_parent"<br /> tools:context=".MapActivity" ><br /> <br /> <br /> <ZoomControls<br /> android:id="@+id/zoomControls1"<br /> android:layout_width="wrap_content"<br /> android:layout_height="wrap_content"<br /> android:layout_alignParentBottom="true"<br /> android:layout_alignParentRight="true"<br /> android:layout_marginBottom="52dp"<br /> android:layout_marginRight="20dp" /><br /><br /> <WebView<br /> android:id="@+id/webView1"<br /> android:layout_width="match_parent"<br /> android:layout_height="match_parent" <br /> android:layout_alignParentTop="true"<br /> /><br /><br /></RelativeLayout></span><br />
<br />
Now vopy the following code in the oncreate method,in <span style="background-color: lime;">ActivityMain.Java</span> file<br />
<br />
<span style="color: red;">@Override<br /> protected void onCreate(Bundle savedInstanceState) {<br /> super.onCreate(savedInstanceState);<br /> setContentView(R.layout.activity_map);<br /> // Show the Up button in the action bar.<br /> //getActionBar().setDisplayHomeAsUpEnabled(true);<br /> <br /> WebView WV = (WebView)findViewById (R.id.webView1);<br /> WV.loadUrl("file:///android_asset/<span style="background-color: lime;"><span style="color: black;">kerala.jpg</span></span>");<br /> WV.getSettings().setBuiltInZoomControls(true);<br /> WV.getSettings().setSupportZoom(true);<br /> <br /> }</span><br />
<br />
You are done.Dont forget to replace the <span style="background-color: lime;">kerala.jpg</span> file name with your filename of picture. Just run the application yoiu will find the picture as zoomable.<br />
<br />Arise Rayamangalamhttp://www.blogger.com/profile/17522192478676631711noreply@blogger.com9tag:blogger.com,1999:blog-9176720325012787290.post-78581557078180855392013-03-20T09:45:00.001-07:002014-10-10T23:59:15.034-07:00d. Databse and Spinner TutorialIn this Tutorial you will learn how to retrieve the Data from a Database through Android Application and how to use a spinner to select database data.(spinner is nothing but the modified form of drop down list used in html) The Database supported in Android is "SQLITE", which is a light open source Database which can be used for data insertion in Linux and Windows. SQL Database will run in all Android Devices without any pre installation or setup.<br />
<br />
<span style="background-color: lime;">(TIP)source code is avialble at the bottom </span><br />
<br />
There are two method by which you can use a Database in Android. One is by creating a Database through the application and insetion of data through the Java code itself. The other one is by attaching a Database with data to the application. Even though the first method seems to be simpler, if you want to insert say 50 data in to the database it is quite difficult and your code will look shabby. Editing the data and finding the data in code will also be difficult. In the second method we add data to the Database externally using a Database Manager and and attach it to the application in "assets" folder. The data insertion using this method is very simple and fast, even any external person can do this job.Here we are going to learn the second method<br />
<br />
The first thing to do is downloading a suitable SQLITE database manger. I will suggest you to use Database Manger comes as a Firefox extension. It very low in size and easy to use with all facilities. Just search SQLite manger in Firefox addons (Tools>addons in Firefox). After getting the Database Manger we have to insert data in to it.<br />
<br />
Click Tools>SQLite manger in Firefox and Click create database and give the name "Sample_database"<br />
then create a new table named data as shown in the figure below.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-mCQJn01KY_w/UUnWoheEM3I/AAAAAAAAArY/rvlR0870RyY/s1600/Workspace+1_001.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-mCQJn01KY_w/UUnWoheEM3I/AAAAAAAAArY/rvlR0870RyY/s640/Workspace+1_001.jpeg" height="358" width="640" /></a></div>
<br />
Give the table name as "data". Now insert the following column names respectively, "name","age","sex"and _id"<br />
click ok to create the table as shown below.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-rWx5l5jsQWk/UUnXRPqFPBI/AAAAAAAAArg/fbC8k1qZVDU/s1600/SQLite+Manager+-+Create+Table_002.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-rWx5l5jsQWk/UUnXRPqFPBI/AAAAAAAAArg/fbC8k1qZVDU/s640/SQLite+Manager+-+Create+Table_002.jpeg" height="400" width="640" /></a></div>
<br />
From the "browse and search" tab click "add" to add a new record and give the details as follows name:arise,age:31,sex:Male,_id:1 click ok to create the record.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-RelDYrrfZW8/UUnXzeUbw0I/AAAAAAAAAro/2wEvAgIOK9U/s1600/Add+New+Record_003.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-RelDYrrfZW8/UUnXzeUbw0I/AAAAAAAAAro/2wEvAgIOK9U/s640/Add+New+Record_003.jpeg" height="530" width="640" /></a></div>
<br />
<br />
Similarly add the following data to the table<br />
name:Raman,age:40,sex:Male,_id:2 then,<br />
name:Sita,age:35, sex:Female,_id:3<br />
<br />
Inorder the database to be worked on Android we have to add a table named "Android Metadata". We can add this through script. "Click Execute SQL" tab and copy pase the following two lines one by one,<span style="color: #993333; font-weight: bold;"> </span>as shown in figure below.<span style="color: #993333; font-weight: bold;"><br /></span><br />
<br />
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: red;">"android_metadata"</span> <span style="color: #66cc66;">(</span><span style="color: red;">"locale"</span> TEXT <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: red;">'en_US'</span><br />
<br />
<span style="color: #66cc66;"></span><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: red;">"android_metadata"</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">(</span><span style="color: red;">'en_US'</span><span style="color: #66cc66;">)</span><br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-dxvJEzokDyY/UUnZ2lrYQdI/AAAAAAAAArw/7rY0syvo5bw/s1600/Workspace+1_004.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-dxvJEzokDyY/UUnZ2lrYQdI/AAAAAAAAArw/7rY0syvo5bw/s640/Workspace+1_004.jpeg" height="358" width="640" /></a></div>
<br />
Now our database is ready to attach with the application. The database file will have sqlite extension it is not required so delete the extension.<br />
<br />
Now <span style="background-color: yellow;">create</span> a <span style="background-color: yellow;">new project</span> named "<span style="background-color: yellow;">Database</span>" with package name "com.example.database"<br />
<br />
Here we are creating a <span style="background-color: yellow;">spinner for getting the data</span> from user and a button to execute the Database operation. The <span style="background-color: yellow;">result</span> will be displayed in a <span style="background-color: yellow;">Table Layout</span>. A TextView will be used for showing the instruction to the user.<br />
copy the following code in to the <span style="background-color: yellow;">activity_main.xml</span> file<br />
Also copy the Database file just we have created named "Sample_database" in to assets folder. <br />
<br />
<span style="color: blue;"><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br /> xmlns:tools="http://schemas.android.com/tools"<br /> android:layout_width="match_parent"<br /> android:layout_height="match_parent"<br /> android:orientation="vertical"<br /> tools:context=".MainActivity" ><br /><br /> <TextView<br /> android:id="@+id/textView1"<br /> android:layout_width="wrap_content"<br /> android:layout_height="wrap_content"<br /> android:text="Find the Database data based on gender" /><br /><br /> <Spinner<br /> android:id="@+id/spinner1"<br /> android:layout_width="170dp"<br /> android:layout_height="wrap_content"<br /> android:layout_marginTop="15dp" <br /> /><br /><br /> <Button<br /> android:id="@+id/button1"<br /> android:layout_width="wrap_content"<br /> android:layout_height="wrap_content" <br /> android:onClick="RunDatabse"<br /> android:text="Button" /><br /> <br /><br /> <TableLayout<br /> android:id="@+id/tableLayout1"<br /> android:layout_width="fill_parent"<br /> android:layout_height="wrap_content"<br /> android:layout_marginTop="13dp" <br /> android:stretchColumns="*"<br /> ><br /> <br /> </TableLayout><br /><br /></LinearLayout> </span><br />
<br />
Now in the <span style="background-color: yellow;">MainActivity.java</span> file copy the following code. the step by step information is given as comments so read the comments.<br />
<br />
<span style="color: #073763;">package com.example.database;</span><br />
<span style="color: #073763;"><br />import java.io.IOException;<br />import android.app.Activity;<br />import android.content.res.Resources;<br />import android.database.SQLException;<br />import android.graphics.Typeface;<br />import android.os.Bundle;<br />import android.view.View;<br />import android.widget.Adapter;<br />import android.widget.AdapterView;<br />import android.widget.ArrayAdapter;<br />import android.widget.Spinner;<br />import android.widget.TableLayout;<br />import android.widget.TableRow;<br />import android.widget.TextView;<br />import android.widget.AdapterView.OnItemSelectedListener;<br />import android.widget.Toast;<br /><br />public class MainActivity extends Activity {<br /> private String[] mystring;<span style="color: lime;">//creating a string array named mystring</span><br /> Spinner samplespinner; <span style="color: lime;">//Assigning a name for spinner</span><br /> String[] DataToDB;<span style="color: lime;">//defining a string array named DataToDB</span><br /> String[]result_array;<span style="color: lime;">//defining an array for saving the results obtained from DB</span><br /> String Selecteditem;<span style="color: lime;">//Defining a string for storing selected item from spinner</span><br /><br /> @Override<br /> protected void onCreate(Bundle savedInstanceState) {<br /> super.onCreate(savedInstanceState);<br /> setContentView(R.layout.activity_main);<br /><br /> ///////////////////SPINNER/////////////////////////<br /> <br /> ArrayAdapter sampleadapter;<span style="color: lime;">//Assigning a name for ArrayAdapter</span><br /> <br /> Resources res = getResources();<span style="color: lime;">//Assigning a name for Resources</span><br /> <br /> mystring = res.getStringArray(R.array.Sex);<span style="color: lime;">//getting the array items to string named my string</span><br /> //mystring is an array which is defined on the top<br /> <br /> samplespinner= (Spinner) findViewById(R.id.spinner1); <span style="color: lime;">//samplespinner is defined in the top </span><br /> <span style="color: lime;"> //samplespinner is the name given to the spinner at the top</span><br /> <br /> sampleadapter = new ArrayAdapter<String>(this,<br /> android.R.layout.simple_spinner_item, mystring);<br /> samplespinner.setAdapter(sampleadapter);<br /> <br /> samplespinner.setOnItemSelectedListener(new OnItemSelectedListener()<br /> {<br /> public void onItemSelected(AdapterView<?> arg0, View arg1,<br /> int arg2, long arg3)<br /> {<br /> //Toast.makeText(getBaseContext(), spVIA.getSelectedItem().toString(),<br /> //Toast.LENGTH_LONG).show(); <br /> <br /> Selecteditem = samplespinner.getSelectedItem().toString();<br /> }<br /> public void onNothingSelected(AdapterView<?> arg0)<br /> {<br /> // TODO Auto-generated method stub <br /> }<br /> });} <br /> //////////////////////////SPINNER ENDS///////////////////////////////////////////////////<br /> <br /> ////////////////////////////DATABASE////////////////////////////////////////////////////<br /> public void RunDatabse(View view) {<br /> DatabaseHelper myDbHelper = new DatabaseHelper(this);<br /> //Toast.makeText(this,Selecteditem,Toast.LENGTH_LONG).show();<br /> <br /> try {<br /> <br /> myDbHelper.createDataBase();<br /> DataToDB = myDbHelper.ReadFromDB(Selecteditem.trim());//sending the selected spinner item to database for query<br /> TableLayout tablelayout1= (TableLayout)findViewById(R.id.tableLayout1);<br /> tablelayout1.removeAllViews();<br /> <span style="color: lime;"> //Adding raws to the Table dynamically</span><br /> for(int i=0;i < DataToDB.length;i++)//repeat adding raws to the table layout till the string array length ends<br /> {<br /> <br /> <br /> TableRow tR = new TableRow(this);<br /> result_array = DataToDB[i].split(","); <span style="background-color: white;">/<span style="color: lime;">/splitting the comma separated string array</span></span><br /> <span style="color: lime;"> //result_array is the string array for storing result.it is defined in top </span><br /> tR.setPadding(5,5,5,5);<span style="color: lime;"> //setting spacing between table raws </span> <br /> TextView tV_txt1 = new TextView(this);<span style="color: lime;">//adding textViews to each Table cell</span><br /> TextView tV_txt2 = new TextView(this);<br /> TextView tV_txt3 = new TextView(this);<br /> <br /> <br /> tV_txt1.setText(result_array[0]);<span style="color: lime;">//setting the first array item to text </span>view<br /> <br /> <br /> tV_txt2.setText(result_array[1]);<br /> <br /> <br /> tV_txt3.setText(result_array[2]);<br /> <br /> <br /> <br /> tR.addView(tV_txt1);<br /> tR.addView(tV_txt2);<br /> tR.addView(tV_txt3);<br /> <br /><br /> tablelayout1.addView(tR);<span style="color: lime;">//Adding all Table raws to the Table</span><br /> <br /> } <br /> <br /> }<br /> catch (IOException ioe) {<br /> <br /> throw new Error("Unable to create database");<br /> <br /> }<br /> <br /> try {<br /> <br /> try {<br /> myDbHelper.openDataBase();<br /> } catch (java.sql.SQLException e) {<br /> // TODO Auto-generated catch block<br /> e.printStackTrace();<br /> }<br /> <br /> }catch(SQLException sqle){<br /> <br /> throw sqle;<br /> <br /> } <br /> }<br />}</span><br />
<span style="color: #073763;"><span style="color: black;"></span></span><br />
<br />
Here what we are doing is first loading the data stored in the Strings.xml file in to the spinner. The value of spinner items will be stored in to an string and it will be send to the database for query. The database will be read using code through a new java file which will be explained later.<br />
<br />
Now copy the following code in to the <span style="background-color: yellow;">strings.xml</span> file in the values folder,<br />
<span style="color: blue;"><br /></span>
<span style="color: blue;"><?xml version="1.0" encoding="utf-8"?><br /><resources><br /><br /> <string name="app_name">database</string><br /> <string name="hello_world">Hello world!</string><br /> <string name="menu_settings">Settings</string><br /> <item type="string" name="databaseVersion" format="integer">1</item><br /><string-array name="Sex"><br /> <item >Male</item><br /> <item >Female</item><br /> <br /></string-array><br /></resources></span><br />
<br />
Here the string array name is "SEX" and the vlaues of array will be (Male, Female) which will be given as items. So What we are going to do is <span style="background-color: yellow;">when</span> the <span style="background-color: yellow;">user select the Gender</span> ie. Male or Female the <span style="background-color: yellow;">data corresponding in the database will be shown to the user.</span><br />
<br />
Now create a new CLass (Java file) called <span style="background-color: yellow;">"DatabaseHelper"</span> by right clicking on the package name "com.example.database" and select <span style="background-color: yellow;">new>class</span> give the above name for the java file.<br />
Now cpy pase the following code in to the java file,<br />
<br />
<span style="color: blue;">package com.example.database;<br /><br /><br />import java.io.FileOutputStream;<br />import java.io.IOException;<br />import java.io.InputStream;<br />import java.io.OutputStream;<br />import java.sql.SQLException;<br />import java.util.ArrayList;<br /><br />import android.content.ContentValues;<br />import android.content.Context;<br />import android.database.Cursor;<br />import android.database.sqlite.SQLiteDatabase;<br />import android.database.sqlite.SQLiteException;<br />import android.database.sqlite.SQLiteOpenHelper;<br />import android.widget.Toast;<br /><br />public class DatabaseHelper extends SQLiteOpenHelper{<br /> <br />//The Android's default system path of your application database.<br />private static String DB_PATH = "/data/data/com.example.database/databases/";<br /><br /><br />private static String DB_NAME = "Sample_databse";<span style="color: lime;">//name of your Database</span><br /><br />private SQLiteDatabase myDataBase;<br /><br />private final Context myContext;<br /><br />/**<br /> * Constructor<br /> * Takes and keeps a reference of the passed context in order to access to the application assets and resources.<br /> * @param context<br /> */<br />public DatabaseHelper(Context context) {<br /><br /> super(context, DB_NAME, null, 1);<br /> this.myContext = context;<br />}<br /><br />/**<br /> * Creates a empty database on the system and rewrites it with your own database.<br /> * */<br />public void createDataBase() throws IOException{<br /><br /> boolean dbExist = checkDataBase();<br /><br /><br /><br /><br />if(dbExist)<br /> {<br /> //do nothing - database already exist<br /> <br /> //Toast.makeText(this.myContext,"Db Exists",Toast.LENGTH_LONG).show();<br /> <br /> <br /> }<br />else{<br /><br /> //By calling this method and empty database will be created into the default system path<br /> //of your application so we are gonna be able to overwrite that database with our database.<br /> this.getReadableDatabase();<br /> <br /> //Toast.makeText(this.myContext,"Create new DB",Toast.LENGTH_LONG).show();<br /> <br /> try {<br /> <br /> copyDataBase();<br /> <br /> //Toast.makeText(this.myContext,"Copy DB",Toast.LENGTH_LONG).show();<br /> <br /> } catch (IOException e) {<br /> <br /> throw new Error("Error copying database");<br /> <br /> }<br /> }<br /><br /><br />}<br /><br /><br /> public String[] ReadFromDB(String Selecteditem) {<br /> // Retrieve a string array of all our Data<br /> //Toast.makeText(this.myContext,"Read From DB",Toast.LENGTH_LONG).show();<br /> <br /> ArrayList temp_array = new ArrayList();<br /> String[] notes_array = new String[0];<br /> //The SQL Query<br /> <br /> <br /> String sqlQuery = "SELECT * FROM data where sex = '"+ Selecteditem +"'" ; <br /> <br /> <span style="color: lime;"> //Here we are querying the databse with the selected item from the spinner. Only the data with the selected item will be retrieved from the database </span> <br /> <br /> //Define database and cursor<br /> <br /> //Toast.makeText(this.myContext,sqlQuery,Toast.LENGTH_LONG).show();<br /> <br /> SQLiteDatabase db = this.getWritableDatabase();<br /> Cursor c = db.rawQuery(sqlQuery, null);<br /><br /> <span style="color: lime;">//Loop through the results and add it to the temp_array</span><br /> <span style="color: lime;">//You shoud give the column names in the Database exactly here below</span> <br /> <br /> if (c.moveToFirst()){<br /> do{<br /> temp_array.add( c.getString(c.getColumnIndex("name")) +<br /> "," + c.getString(c.getColumnIndex("age")) +<br /> "," + c.getString(c.getColumnIndex("sex")) <br /> );<br /> <br /> //Toast.makeText(this.myContext,c.getString(c.getColumnIndex("TIME")),Toast.LENGTH_LONG).show();<br /> <br /> <br /> <br /> <br /> }while(c.moveToNext());<br /> }<br /> //Close the cursor<br /> c.close();<br /> //Transfer from the ArrayList to string array<br /> notes_array = (String[]) temp_array.toArray(notes_array);<br /> //Return the string array<br /> return notes_array;<br /> }<br /> <br /><br /> <br />/**<br /> * Check if the database already exist to avoid re-copying the file each time you open the application.<br /> * @return true if it exists, false if it doesn't<br /> */<br />private boolean checkDataBase(){<br /><br /> SQLiteDatabase checkDB = null;<br /> <br /> //Toast.makeText(this.myContext,"check db",Toast.LENGTH_LONG).show();<br /> <br /> try{<br /> String myPath = DB_PATH + DB_NAME;<br /> checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);<br /> <br /> //Toast.makeText(this.myContext,myPath,Toast.LENGTH_LONG).show();<br /> <br /> <br /> }catch(SQLiteException e){<br /> <br /> //Toast.makeText(this.myContext,"DB Does not exists",Toast.LENGTH_LONG).show();<br /> <br /> //database does't exist yet.<br /> <br /> }<br /> <br /> if(checkDB != null){<br /> <br /> checkDB.close();<br /> <br /> }<br /> <br /> return checkDB != null ? true : false;<br />}<br /><br />/**<br /> * Copies your database from your local assets-folder to the just created empty database in the<br /> * system folder, from where it can be accessed and handled.<br /> * This is done by transfering bytestream.<br /> * */<br />private void copyDataBase() throws IOException{<br /><br /> <span style="color: lime;"> //Open your local db as the input stream</span><br /> InputStream myInput = myContext.getAssets().open(DB_NAME);<br /> <span style="background-color: white;"> <br /> <span style="color: lime;"> // Path to the just created empty db</span></span><br /> String outFileName = DB_PATH + DB_NAME;<br /> <br /> <span style="color: lime;"> //Open the empty db as the output stream</span><br /> OutputStream myOutput = new FileOutputStream(outFileName);<br /> <br /> <span style="color: lime;"> //transfer bytes from the inputfile to the outputfile</span><br /> byte[] buffer = new byte[1024];<br /> int length;<br /> while ((length = myInput.read(buffer))>0){<br /> myOutput.write(buffer, 0, length);<br /> }<br /> <br /> //Close the streams<br /> myOutput.flush();<br /> myOutput.close();<br /> myInput.close();<br /><br />}<br /><br />public void openDataBase() throws SQLException{<br /><br /> <span style="color: lime;"> //Open the database</span><br /> String myPath = DB_PATH + DB_NAME;<br /> myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);<br /> <br /><br /><br /><br />}<br /><br />@Override<br />public synchronized void close() {<br /><br /> if(myDataBase != null)<br /> myDataBase.close();<br /> <br /> super.close();<br /><br />}<br /><br />@Override<br />public void onCreate(SQLiteDatabase db) {<br /><br />}<br /><br />@Override<br />public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {<br /><br />}<br /><br /> // Add your public helper methods to access and get content from the database.<br /> // You could return cursors by doing "return myDataBase.query(....)" so it'd be easy<br /> // to you to create adapters for your views.<br /><br />}</span><br />
<br />
Android <span style="background-color: yellow;">cannot execute</span> the database <span style="background-color: yellow;">directly from the asset folder</span> so it first load it in to the system folder and run it from there. Your <span style="background-color: yellow;">database</span> will be <span style="background-color: yellow;">stored</span> <span style="background-color: yellow;">in</span> the following location <span style="color: blue;">"<span style="color: black;"><span style="background-color: yellow;">/data/data/com.example.database/databases/</span></span>" <span style="color: black;">with the name</span> </span>"<span style="color: blue;"><span style="color: black;"><span style="background-color: yellow;">Sample_databse</span></span>"</span><br />
<br />
<br />
the data is retrived from the database using cursor the following code<br />
<span style="color: blue;">"SELECT * FROM data where sex = '"+ Selecteditem +"'" </span><br />
<span style="color: blue;"><br /></span>
The criteria for selecting the data is <span style="color: blue;">passing</span> through the string named <span style="color: blue;"><span style="color: black;">"<span style="background-color: yellow;">Selecteditem</span>" which was used to store the selected item from the spinner. So <span style="background-color: yellow;">if</span> the <span style="background-color: yellow;">criteria</span> ie the sex column <span style="background-color: yellow;">matches</span> the <span style="background-color: yellow;">selected item in spinner</span> for example "Male" all the <span style="background-color: yellow;">data</span> having the gender as "male" <span style="background-color: yellow;">will be retrived</span> and shown to the user. In the cursor you should give the exact column name given in the Database (See he comment in th</span></span><span style="color: blue;"><span style="color: black;"><span style="color: blue;"><span style="color: black;">e code</span></span>) Then we <span style="background-color: yellow;">store it</span> in a string array <span style="background-color: yellow;">and</span> <span style="background-color: yellow;">pass it back</span> to the <span style="background-color: yellow;">MainActivity</span> to show the result in the Table Layout. Here we don't know how many data will be retrieved so we use a <span style="background-color: yellow;">dynamic</span> (automatically adding raws to the Table layout) <span style="background-color: yellow;">method</span> to display the data. Please note that <span style="background-color: yellow;">in Table layout</span> we have to<span style="background-color: yellow;"> add TextViews to</span> <span style="background-color: yellow;">each cell</span> in order to display the text.</span></span><br />
<br />
<span style="color: blue;"><span style="color: black;">When you run the application you will get the result as follows,</span></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-JFwp78ND63I/UUnkNcUK1lI/AAAAAAAAAsA/xcR76X1AoQg/s1600/5554:smart_005.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-JFwp78ND63I/UUnkNcUK1lI/AAAAAAAAAsA/xcR76X1AoQg/s320/5554:smart_005.jpeg" height="320" width="261" /></a></div>
<br />
<br />
<br />
Now we have learn how to use a spinner,SQLite database and Table Layout.<br />
<span style="background-color: lime;">You may download the code by clicking the following link</span><br />
<a href="http://rapidshare.com/files/2602646334/Database.zip" target="_blank"><br /></a>
<a href="https://www.dropbox.com/s/5dikbvrzv46g9op/Database.zip?dl=0" target="_blank">DOWNLOAD SOURCE CODE</a><br />
<br />
<br />
<br />Arise Rayamangalamhttp://www.blogger.com/profile/17522192478676631711noreply@blogger.com87tag:blogger.com,1999:blog-9176720325012787290.post-58509119448491272672013-02-22T03:14:00.002-08:002014-10-11T00:01:36.710-07:00c. How to create Tabs using Action BarTo create Tabs in Android Tab-host was used earlier. But since it is deprecated and cannot be used anymore, Tabs using Action bar is a better choice. Google is pushing Android Developers to use Action bar instead of hardware menu since it is visible to the user and easily accessible. Action bar can used to host Tabs,Drop Down Lists, Menu settings and even a share button. The only dis advantage of Action Bar is it require API level 13 (ie. 3.2 , Honey Comb )<br />
<br />
<span style="background-color: lime;">(TIP) Source code given at the bottom</span><br />
<br />
So today we will learn how to host a tabs using Action Bar.For this we have to create a main Java (Class) file two fragments for two tabs, one main XMl file and two XMl files for two tabs.<br />
<br />
First create a project named "Action Bar Tab Sample " as shown below,<br />
Change the package name to "com.<span style="background-color: yellow;">arise</span>.actionbartabsample" instead of "arise" you may use your own name without space. Select minimum SDK required to <span style="background-color: yellow;">API level 13</span>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-5vBHM5dVnFg/UScy9mI35wI/AAAAAAAAAnY/j1S6t_D5U_4/s1600/1.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-5vBHM5dVnFg/UScy9mI35wI/AAAAAAAAAnY/j1S6t_D5U_4/s640/1.jpeg" height="622" width="640" /></a></div>
<br />
Click next in the next screen.<br />
Next you can choose a n Icon for your project. You may click beowse and select <span style="background-color: yellow;">any image</span> as icon, Eclipse will convert it to icon<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/--fn9hlb7rH8/USc7HwK_cFI/AAAAAAAAAng/Br6E_ACQH1c/s1600/2.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/--fn9hlb7rH8/USc7HwK_cFI/AAAAAAAAAng/Br6E_ACQH1c/s640/2.jpeg" height="622" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
Nothing is to be changed in the next screen click next and finish to create your project.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/--cKKzlObvh8/USc7TN6uepI/AAAAAAAAAno/6V00NSgOF10/s1600/3.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/--cKKzlObvh8/USc7TN6uepI/AAAAAAAAAno/6V00NSgOF10/s640/3.jpeg" height="622" width="640" /></a></div>
<br />
<br />
Now create two fragments and two XML file for tabs, as shown below,<br />
right click on the package file ans click new click class to <span style="background-color: yellow;">create a new jave</span> file for 1st Fragment <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-B_dh4OYC3LI/USc7xBcTU7I/AAAAAAAAAnw/NPooRpujq-o/s1600/4.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-B_dh4OYC3LI/USc7xBcTU7I/AAAAAAAAAnw/NPooRpujq-o/s640/4.jpeg" height="358" width="640" /></a></div>
<br />
Give it a name "<span style="background-color: yellow;">Fragment1" </span>as shown below,<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-2p4Rex3Q7fI/USc8O_uvC6I/AAAAAAAAAn4/HzibHmE9Rgc/s1600/5.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-2p4Rex3Q7fI/USc8O_uvC6I/AAAAAAAAAn4/HzibHmE9Rgc/s640/5.jpeg" height="640" width="570" /></a></div>
<br />
Similerly create <span style="background-color: yellow;">"Frgament2"</span> as shown below,<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-OSMK_HrG6xU/USc8fWMXLTI/AAAAAAAAAoA/WkMuJweyhjM/s1600/6.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-OSMK_HrG6xU/USc8fWMXLTI/AAAAAAAAAoA/WkMuJweyhjM/s640/6.jpeg" height="640" width="570" /></a></div>
<br />
<br />
Now create two XMl file by right clicking on the layour folder and click new Android XML file as shown below,<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-0Mm6XRsMQ14/USc9IkAaBaI/AAAAAAAAAoI/fH9jE0jTFlo/s1600/7.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-0Mm6XRsMQ14/USc9IkAaBaI/AAAAAAAAAoI/fH9jE0jTFlo/s640/7.jpeg" height="358" width="640" /></a></div>
<br />
<br />
Name the fist XMl file as "<span style="background-color: yellow;">tab1</span>" as shown below,<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-JyU7eAQFlvs/USc9c2cQzTI/AAAAAAAAAoQ/m4k6PiLfsQs/s1600/8.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-JyU7eAQFlvs/USc9c2cQzTI/AAAAAAAAAoQ/m4k6PiLfsQs/s640/8.jpeg" height="602" width="640" /></a></div>
<br />
Similarly create another XML file and give the name "<span style="background-color: yellow;">tab2</span>" as shown below,<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-c6BjXv4M32M/USc9yFRgzSI/AAAAAAAAAoY/_E1djzobxm8/s1600/9.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-c6BjXv4M32M/USc9yFRgzSI/AAAAAAAAAoY/_E1djzobxm8/s640/9.jpeg" height="602" width="640" /></a></div>
<br />
Now we have to create <span style="background-color: yellow;">two buttons</span> <span style="background-color: yellow;">in</span> each <span style="background-color: yellow;">Fragmen</span>t and <span style="background-color: yellow;">one common EditTex</span>t for both buttons in Main XML file named<span style="background-color: yellow;"> activity_main.xml</span>. <br />
<br />
First copy the following code in to the Main XML file named activity_main.XMl in the layout folder<br />
Here we are creating a common EditText so that when the buttons are clicked the text will be displayed in the EditText <br />
<span style="color: blue;"><span style="background-color: white;"><br /></span></span>
<span style="color: blue;"><span style="background-color: white;"><?xml version="1.0" encoding="utf-8"?><br /><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br /> android:layout_width="match_parent"<br /> android:layout_height="wrap_content"<br /> android:orientation="vertical"<br /> ></span></span><span style="color: blue;"><span style="background-color: white;"><br /> <br /> <EditText<br /> android:id="@+id/editText1"<br /> android:layout_width="match_parent"<br /> android:layout_height="wrap_content"<br /> android:inputType="textMultiLine" <br /> android:textIsSelectable="true" > <br /> <requestFocus /> <br /> </EditText> <br /> <br /> </LinearLayout></span></span><br />
<br />
<br />
<br />
Now copy the following code in to the <span style="background-color: yellow;">MainActivity.java</span> file in the package ,<br />
package com.arise.actionbartabsample; Now I am using Malayalam language custon font for this application so I have to save the font to assets folder and set Typeface as shown below.<br />
<br />
<span style="color: blue;">import android.os.Bundle;<br />import android.app.ActionBar;<br />import android.app.Activity;<br />import android.app.Fragment;<br />import android.app.FragmentTransaction;<br />import android.app.ActionBar.Tab;<br />import android.graphics.Typeface;<br />import android.view.Menu;<br />import android.view.View;<br />import android.widget.Button;<br />import android.widget.EditText;<br /><br />public class MainActivity extends Activity {<br /><br /> @Override<br /> protected void onCreate(Bundle savedInstanceState) {<br /> super.onCreate(savedInstanceState);<br /> setContentView(R.layout.activity_main);<br /> <br /> <br /> final ActionBar actionBar = getActionBar(); <br /> actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); <br /> <br /> <span style="color: lime;"> //setting tabs in to the Action Bar</span><br /> Tab tabA = actionBar.newTab(); <span style="color: lime;"> //Setting Tab A </span> <br /> tabA.setTabListener(new TabListener<Fragment1>(this, "Tag A", Fragment1.class));<br /> tabA.setIcon(R.drawable.tab1);<span style="color: lime;"> <span style="background-color: white;">//Setting an Icon for Tab A</span></span><br /> tabA.setText("A"); <span style="color: lime;">//Setting Title for Tab A</span><br /> actionBar.addTab(tabA); <span style="color: lime;">//Adding tab to the Action Bar</span><br /> <br /> Tab tabB = actionBar.newTab();<br /> tabB.setIcon(R.drawable.tab2);<br /> tabB.setText("B"); ; <br /> tabB.setTabListener(new TabListener<Fragment2>(this, "Tag B", Fragment2.class));<br /> actionBar.addTab(tabB);<br /> <br /> if (savedInstanceState != null) {<br /> int savedIndex = savedInstanceState.getInt("SAVED_INDEX");<br /> getActionBar().setSelectedNavigationItem(savedIndex);<br /> }<br /> <br /> }<br /> @Override<br /> protected void onSaveInstanceState(Bundle outState) {<br /> // TODO Auto-generated method stub<br /> super.onSaveInstanceState(outState);<br /> outState.putInt("SAVED_INDEX", getActionBar().getSelectedNavigationIndex());<br /> <br /> }<br /><br /> public static class TabListener<T extends Fragment> <br /> implements ActionBar.TabListener{<br /> <br /> private final Activity myActivity;<br /> private final String myTag;<br /> private final Class<T> myClass;<br /><br /> public TabListener(Activity activity, String tag, Class<T> cls) {<br /> myActivity = activity;<br /> myTag = tag;<br /> myClass = cls;<br /> <br /> }<br /><br /> @Override<br /> public void onTabSelected(Tab tab, FragmentTransaction ft) {<br /><br /> Fragment myFragment = myActivity.getFragmentManager().findFragmentByTag(myTag);<br /> <br /> // Check if the fragment is already initialized<br /> if (myFragment == null) {<br /> // If not, instantiate and add it to the activity<br /> myFragment = Fragment.instantiate(myActivity, myClass.getName());<br /> ft.add(android.R.id.content, myFragment, myTag);<br /> <br /> } else {<br /> // If it exists, simply attach it in order to show it<br /> ft.attach(myFragment);<br /> }<br /> <br /> <br /> }<br /><br /> @Override<br /> public void onTabUnselected(Tab tab, FragmentTransaction ft) {<br /> <br /> Fragment myFragment = myActivity.getFragmentManager().findFragmentByTag(myTag);<br /> <br /> if (myFragment != null) {<br /> // Detach the fragment, because another one is being attached<br /> ft.detach(myFragment);<br /> }<br /> <br /> }<br /><br /> @Override<br /> public void onTabReselected(Tab tab, FragmentTransaction ft) {<br /> // TODO Auto-generated method stub<br /> <br /> }<br /> <br /> }<br /> public void button_method1(View view)<span style="color: lime;"> //Setting method for Button 1</span><br /> <br /> {</span><br />
<span style="color: blue;"></span><br />
<span style="color: blue;"> <span style="color: lime;">//setting Malayalam font for the EditText</span><br /> EditText et = (EditText)findViewById(R.id.editText1); <br /> Typeface typeFace1 = Typeface.createFromAsset(getAssets(),"fonts/AnjaliOldLipi.ttf");<br /> et.setTypeface(typeFace1);<br /> et.append("അ,A"); <span style="color: lime;">//I have used append instead of SetText for adding the text to the already printed text. Otherwise it will replace the first</span><br /> }<br /> public void button_method2 (View view) <span style="color: lime;">//Method for Button2</span><br /> <br /> {</span><br />
<span style="color: blue;"> </span><br />
<span style="color: blue;"><span style="color: blue;"><span style="color: lime;">//setting Malayalam font for the EditText</span></span></span><br />
<span style="color: blue;"><span style="color: blue;"><span style="color: lime;"> </span></span> EditText et = (EditText)findViewById(R.id.editText1); <br /> Typeface typeFace1 = Typeface.createFromAsset(getAssets(),"fonts/AnjaliOldLipi.ttf");<br /> et.setTypeface(typeFace1);<br /> et.append("ആ,B");<br /> }<br /> <br /> }</span><br />
<br />
To create the Button1 in <span style="background-color: yellow;">Tab1.xml </span>file copy the following code,<br />
We have to give a margin at top so that the EditText and button should not overlap.<br />
<br />
<span style="color: blue;"><?xml version="1.0" encoding="utf-8"?><br /><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br /> android:layout_width="wrap_content"<br /> android:layout_height="wrap_content"<br /> android:orientation="vertical"<br /> android:layout_marginTop="100dp"<br /> android:gravity="center_horizontal" > <br /> <Button<br /> android:id="@+id/button1"<br /> android:layout_width="wrap_content"<br /> android:layout_height="wrap_content" <br /> android:onClick="button_method1" <br /> /> <br /> <br /><br /></LinearLayout></span><br />
<br />
<br />
<br />
<br />
Now copy the following code in to <span style="background-color: yellow;">Fragment1</span><br />
<br />
package com.arise.actionbartabsample;<br />
<span style="color: blue;"><br />import android.app.Fragment;<br />import android.graphics.Typeface;<br />import android.os.Bundle;<br />import android.view.LayoutInflater;<br />import android.view.View;<br />import android.view.ViewGroup;<br />import android.widget.Button;<br /><br />public class Fragment1 extends Fragment {<br /><br /> @Override<br /> public View onCreateView(LayoutInflater inflater, ViewGroup container,<br /> Bundle savedInstanceState) {<br /> View myFragmentView = inflater.inflate(R.layout.tab1, container, false);<br /> <span style="color: lime;"> //Setting Malayalam font for the Button1</span><br /> Typeface typeFace1 = Typeface.createFromAsset(myFragmentView.getContext().getAssets(),"fonts/AnjaliOldLipi.ttf");<br /><span style="color: lime;"> //Please note that "createFromAsset(getAssets()" will not work in Fragamant</span><br /> Button button_1 = (Button) myFragmentView.findViewById(R.id.button1); <br /> <span style="color: lime;"> //Please note that (Button)findViewById(R.id.button1) will not work in Fragment</span><br /> button_1.setTypeface(typeFace1);<br /> button_1.setText("അ,A");<br /> <br /> return myFragmentView;<br /> <br /> } <br /> <br /><br /> }</span><br />
<br />
Now create the second button, named <span style="background-color: yellow;">button2</span> in the <span style="background-color: yellow;">Fragment2</span> by copying the code below,<br />
<br />
<span style="color: blue;"><?xml version="1.0" encoding="utf-8"?><br /><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br /> android:layout_width="wrap_content"<br /> android:layout_height="wrap_content"<br /> android:layout_marginTop="100dp"<br /> android:gravity="center_horizontal"<br /> android:orientation="vertical" ><br /> <br /> <Button<br /> android:id="@+id/button2"<br /> android:layout_width="wrap_content"<br /> android:layout_height="wrap_content" <br /> android:onClick="button_method2" <br /> /> <br /></LinearLayout></span><br />
<br />
<br />
Now copy the following code in to the <span style="background-color: yellow;">Fragment2.java</span> file<br />
<br />
<span style="color: blue;">package com.arise.actionbartabsample;<br /><br />import android.app.Fragment;<br />import android.graphics.Typeface;<br />import android.os.Bundle;<br />import android.view.LayoutInflater;<br />import android.view.View;<br />import android.view.ViewGroup;<br />import android.widget.Button;<br /><br />public class Fragment2 extends Fragment {<br /><br /> @Override<br /> public View onCreateView(LayoutInflater inflater, ViewGroup container,<br /> Bundle savedInstanceState) {<br /> View myFragmentView = inflater.inflate(R.layout.tab2, container, false);<br /> <span style="color: lime;"><span style="background-color: white;"> //Creating button text using Malayalam font for button2</span></span><br /> Typeface typeFace1 = Typeface.createFromAsset(myFragmentView.getContext().getAssets(),"fonts/AnjaliOldLipi.ttf");<br /> <span style="color: lime;"> //Please note that "createFromAsset(getAssets()" will not work in Fragment</span><br /> Button button_2 = (Button) myFragmentView.findViewById(R.id.button2); <br /> <span style="color: lime;"> //Please note that (Button)findViewById(R.id.button1) will not work in Fragment</span><br /> button_2.setTypeface(typeFace1);<br /> button_2.setText("ആ,B");<br /> <br /> return myFragmentView;<br /> <br /> } <br /> <br /><br /> }</span><br />
You have to save the custom language font (If you want Local Language in your application) to the <span style="background-color: yellow;">assets</span> folder by creating a new folder named "<span style="background-color: yellow;">fonts</span>" folder as shown below,<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-x1_kiUIoj5g/USdFphmbTQI/AAAAAAAAAog/KDMWO44FLuE/s1600/Workspace+1_001.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-x1_kiUIoj5g/USdFphmbTQI/AAAAAAAAAog/KDMWO44FLuE/s640/Workspace+1_001.jpeg" height="358" width="640" /></a></div>
<br />
Now we have to give two icons for each tab, to do that open<span style="background-color: yellow;"> Android manifest </span>File and click "<span style="background-color: yellow;">Applications</span>" tab and click "<span style="background-color: yellow;">browse</span>" next to "icons"as shown below<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-YnKU_1-5Eiw/USdHxiLqKlI/AAAAAAAAAoo/0pNmjoTK-dU/s1600/10.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-YnKU_1-5Eiw/USdHxiLqKlI/AAAAAAAAAoo/0pNmjoTK-dU/s640/10.jpeg" height="358" width="640" /></a></div>
now click on "<span style="background-color: yellow;">Create new icons</span>" as shown below,<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-A5d0HN8V8_4/USdIggjR-VI/AAAAAAAAAow/DtwiMfhDNuE/s1600/11.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-A5d0HN8V8_4/USdIggjR-VI/AAAAAAAAAow/DtwiMfhDNuE/s640/11.jpeg" height="640" width="482" /></a></div>
<br />
<br />
Now give the icon a name "<span style="background-color: yellow;">tab1</span>" as shown below,<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-F4s8Q3f_pno/USdIzxMw43I/AAAAAAAAAo4/ruVWqGmuPus/s1600/12.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-F4s8Q3f_pno/USdIzxMw43I/AAAAAAAAAo4/ruVWqGmuPus/s640/12.jpeg" height="622" width="640" /></a></div>
<br />
Now <span style="background-color: yellow;">choose an icon </span>as shown below,<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-HdsdLWYp5es/USdJIgQeI6I/AAAAAAAAApA/0_phjTUN0Ok/s1600/13.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-HdsdLWYp5es/USdJIgQeI6I/AAAAAAAAApA/0_phjTUN0Ok/s640/13.jpeg" height="622" width="640" /></a></div>
<br />
<br />
<br />
Similarly create another icon with name"<span style="background-color: yellow;">tab2</span>" as shown below,<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-oE7ErerB-9g/USdJYmmC2KI/AAAAAAAAApI/CZ1XDdyai34/s1600/14.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-oE7ErerB-9g/USdJYmmC2KI/AAAAAAAAApI/CZ1XDdyai34/s640/14.jpeg" height="622" width="640" /></a></div>
<br />
Now click <span style="background-color: yellow;">cancel</span> to the child window named "<span style="background-color: yellow;">Resource Chooser</span>" as shown below. Remember Don't give Ok since it will replace your application icon.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-GS5poFuFp8k/USdJzrAdIpI/AAAAAAAAApQ/-aJB-Tk9dG8/s1600/15.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-GS5poFuFp8k/USdJzrAdIpI/AAAAAAAAApQ/-aJB-Tk9dG8/s640/15.jpeg" height="640" width="482" /></a></div>
<br />
Now your project is ready to run,<br />
Click run and choose run as "<span style="background-color: yellow;">Android Application</span>" as shown below,<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-addmGc-itVU/USdKWqg0hTI/AAAAAAAAApY/akDEOVh7s0g/s1600/16.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-addmGc-itVU/USdKWqg0hTI/AAAAAAAAApY/akDEOVh7s0g/s320/16.jpeg" height="320" width="214" /></a></div>
<br />
Now you will get the result in both the tabs when the buttons are clicked<br />
The following screen shows the results when the button 1 in the Tab1 is clicked <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-IbA93_SVO84/USdLBljGE3I/AAAAAAAAApg/0R7eRLnS8os/s1600/5554:smart_002.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-IbA93_SVO84/USdLBljGE3I/AAAAAAAAApg/0R7eRLnS8os/s320/5554:smart_002.jpeg" height="320" width="261" /></a></div>
<br />
The following result shows when the button2 in the Tab2 is clicked,<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-TWkH3sVLjqc/USdLW9i0DHI/AAAAAAAAApo/MwLTf9GiS-4/s1600/5554:smart_003.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-TWkH3sVLjqc/USdLW9i0DHI/AAAAAAAAApo/MwLTf9GiS-4/s320/5554:smart_003.jpeg" height="320" width="261" /></a></div>
<br />
So the project is succesfully completed.<br />
<span style="background-color: lime;">You may Download the</span> <a href="https://www.dropbox.com/s/j8d5e2dwxrqik0h/ActionBarTabSample.zip?dl=0" target="_blank">source code from Here.</a><br />
<br />Arise Rayamangalamhttp://www.blogger.com/profile/17522192478676631711noreply@blogger.com10tag:blogger.com,1999:blog-9176720325012787290.post-17701005580827982992013-02-13T13:17:00.002-08:002014-10-11T00:00:29.716-07:00b. How make a ListView in Android (That also supports Local language)ListView is a nice way to display your text in a list. When the application is launched only the headings will be shown to the user and when the user click on a heading the List item will be shown below. If you want to display some text with main heading ListView provide a nice way to do it.<br />
<br />
In this tutorial we will learn how to make a simple ListView which can also display your local Language Text. (Link to the source code is given at the end)<br />
<br />
Here we require to make a main Java file an Adapter Java file, main xml file, a child xml file and a selector file.<br />
<br />
Create a <span style="background-color: yellow;">New Android Project</span> by clicking as shown in the picture below<br />
<br />
<span style="background-color: yellow;">File>New>Android Application Project</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-0VwwGB6oCrk/URuwzV8zC7I/AAAAAAAAAjg/qpEajKeAxyc/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-0VwwGB6oCrk/URuwzV8zC7I/AAAAAAAAAjg/qpEajKeAxyc/s640/1.png" height="348" width="640" /></a></div>
<br />
<br />
Give the application name as "<span style="background-color: yellow;">CustomLanguageListView</span>".<br />
<br />
In the package name replace the "<span style="background-color: yellow;">example</span>" with "<span style="background-color: yellow;">arise</span>"<br />
<br />
<span style="background-color: lime;">(TIP) </span>Package name with example will not be accepted in Google Play.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-HZhHAJpUoE4/URuxDRSL5LI/AAAAAAAAAjo/iN1VptMj-NA/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-6ol8LFLtUpo/URuxF7ts3mI/AAAAAAAAAjw/EdvQdyTOZE0/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-6ol8LFLtUpo/URuxF7ts3mI/AAAAAAAAAjw/EdvQdyTOZE0/s640/2.png" height="358" width="640" /></a></div>
<br />
<br />
Just <span style="background-color: yellow;">click</span> <span style="background-color: yellow;">next</span> <span style="background-color: yellow;">to</span> the <span style="background-color: yellow;">next three child windows </span>as nothing is to be changed.<br />
<br />
In the Child Window named New Blank Activity <span style="background-color: yellow;">give</span> the activity <span style="background-color: yellow;">name as</span> "<span style="background-color: yellow;">ListViewMainActivity</span>". Layout name will be automatically changed.<br />
Now click Finish to create the Project.<br />
<br />
<a href="http://3.bp.blogspot.com/-HZhHAJpUoE4/URuxDRSL5LI/AAAAAAAAAjo/iN1VptMj-NA/s1600/3.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-HZhHAJpUoE4/URuxDRSL5LI/AAAAAAAAAjo/iN1VptMj-NA/s640/3.png" height="355" width="640" /> </a><br />
Now your Project is created. Now you have to launch the main java file. For that click the following folders.<br />
<br />
<span style="background-color: yellow;">CustomLanguageListView > src > com.arise.customlanguagelistview ></span> <span style="background-color: yellow;">ListViewMainActivity.Java </span><br />
<span style="background-color: yellow;"><br /></span>
<span style="background-color: yellow;"><span style="background-color: white;">Now the main Java file is launched. add the following details to the file.</span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;">For easy understanding I have given the description as comments starting </span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;">with "//" </span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;">What we are doing is creating an ArrayList for the Headings and for List Items and adding each heading and List Items to the ArrayList. I am giving the first Heading as the current date, you can find the code for this below. Since I am going to display local Lnguage text, I have to save the font for the particular language in the "asset" folder, which will be explained later. You have to enter the headings and Items in your chosen language.</span></span><br />
<br />
<span style="color: blue;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="color: black;">Initially some errors will be shown, it will be disappeared when we create the support files.</span></span></span></span><br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="color: blue;">package com.arise.customlanguagelistview;<br /><br /><br />import java.text.DateFormat;<br />import java.util.ArrayList;<br />import java.util.Date;<br />import android.os.Bundle;<br />import android.app.ExpandableListActivity;<br />import android.content.Context;<br />import android.view.LayoutInflater;<br />import android.view.View;<br />import android.widget.ExpandableListView;<br />import android.widget.ExpandableListView.OnChildClickListener;<br /><br />public class ListViewMainActivity extends ExpandableListActivity implements<br />OnChildClickListener {<br /><br /> @Override<br /> protected void onCreate(Bundle savedInstanceState) {<br /> super.onCreate(savedInstanceState);<br /> ExpandableListView expandableLis= getExpandableListView();<br /> expandableLis.setDividerHeight(2);<br /> expandableLis.setGroupIndicator(null);<br /> expandableLis.setClickable(true);<br /> <br /> setGroupData();<br /> setChildGroupData();<br /> <br /> NewAdapter mNewAdapter = new NewAdapter(groupItem,childItem); <br /> mNewAdapter.setInflater((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE),this); <br /> getExpandableListView().setAdapter(mNewAdapter); <br /> expandableLis.setOnChildClickListener(this);<br /> <br /> }<br /> <br /> public void setGroupData()// Setting headings of List View <br /> {<br /> final String currentDateString;//For displaying currentDate and Time in List View<br /> currentDateString = DateFormat.getDateInstance().format(new Date());//When you import Date Format use only import'Date Format' java.text<br /> groupItem.add("ഇന്നത്തെ തിയതി (Today is) - "+currentDateString);//For showing Todays Date along with your Custom Text<br /> groupItem.add("ഹെഡ്ഡിഗ് (Heading) 1");//Adding Heading 2 (You can add more by using add(heading name))<br /> groupItem.add("ഹെഡ്ഡിഗ് (Heading) 2");//Adding heading 2<br /> <br /> }<br /> ArrayList<String> groupItem = new ArrayList<String>();//Setting Headings as Array List<br /> ArrayList<Object>childItem = new ArrayList<Object>(); //Setting List Items as Array List <br /> <br /> public void setChildGroupData()//Adding list Items below the List Headings<br /> {<br /> //Adding List Items to The heading, Date<br /> ArrayList<String> child = new ArrayList<String>();<br /> child.add("ഒരു നല്ല ദിവസം ആശംസിക്കുന്നു. !(Greetings)");//Adding a Item called Greetings below the heading, Date<br /> childItem.add(child);<br /> <br /> //Adding List Items to 1st heading<br /> child = new ArrayList<String>();<br /> child.add ("ഐറ്റം (Item) 1"); //Adding Item 1 to the First heading<br /> child.add ("ഐറ്റം (Item) 2");//Adding Item 2 to the First heading<br /> childItem.add(child);<br /> <br /> //Adding List Items to 2nd heading<br /> child = new ArrayList<String>();<br /> child.add("ഐറ്റം (Item) 3");//Adding Item 1 to the 2nd heading<br /> child.add("ഐറ്റം (Item) 4");//Adding Item 2 to the 2nd heading<br /> childItem.add(child); <br /> <br /> <br /> }<br /> <br /> @Override<br /> public boolean onChildClick (ExpandableListView parent, View v,<br /> int groupPosition, int childPosition, long id) {<br /> return true;<br /> } <br /><br />}</span><br /> </span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;">Now save the Java file and open the Main XML file from th folder shown below</span></span><br />
<br />
<span style="background-color: yellow;">CustomLanguageListView > res > layout >activity_list_view_main.xml</span><br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;">Now copy the following code in to the XML file,</span></span><br />
<br />
<span style="color: blue;"><span style="background-color: yellow;"><span style="background-color: white;"><CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"<br /> xmlns:tools="http://schemas.android.com/tools" <br /> android:id="@+id/textView1" <br /> android:layout_width="wrap_content"<br /> android:layout_height="60dp"<br /> android:layout_marginTop="40dp" <br /> android:layout_marginLeft="5dp" <br /> android:drawableRight="@drawable/iconselector" <br /> android:gravity="center_vertical"<br /> android:text="@string/hello_world"<br /> android:textColor="@color/orange"<br /> android:padding="10dp"<br /> android:textSelectHandleLeft="@string/hello_world"<br /> android:textSize="18sp"<br /> android:textStyle="bold" /> </span></span></span><br />
<br />
<span style="color: blue;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="color: black;">Initially some errors will be shown, it will be disappeared when we create the support files.</span></span></span></span><br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;">Here we are creating a checked TextView for displaying the Headings of the ListView. </span></span><br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;">Here it is given as </span></span><span style="color: blue;"><span style="background-color: yellow;"><span style="background-color: white;">"@drawable/iconselector" <span style="color: black;">it is <span style="background-color: yellow;">a link to the icon selector</span> file. Which we will be creating later. which will be <span style="background-color: yellow;">used for selecting</span> some<span style="background-color: yellow;"> icons </span>during expanding and collapsing as follows,</span></span></span></span><br />
<span style="color: blue;"><span style="background-color: yellow;"><span style="background-color: white;"><br /></span></span></span>
<span style="background-color: yellow;"><span style="background-color: white;">We will give a down arrow icon and an up arrow icon to the heading. When displayed normally the down arrow icon will be shown. so that user can understand that it is an expandable list and some text will be shown below when the down arrow is clicked.</span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;">When the list is fully expanded an up arrow picture is shown so that user can click it and collapse the list.</span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><br /></span></span>
<span style="background-color: yellow;"><span style="background-color: white;">I have want to give the <span style="background-color: yellow;">text color</span> orange to the Heading so a link to the color code in the string.xml file is given as </span></span><span style="background-color: yellow;"><span style="background-color: white;"><span style="color: blue;"><span style="background-color: yellow;"><span style="background-color: white;">"@color/orange"</span></span></span></span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="color: blue;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="color: black;">we will modify the strings.xml file later.</span></span></span></span></span></span><br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="color: blue;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="color: black;"><span style="background-color: yellow;">Save</span> and close the file.</span></span></span></span></span></span><br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="color: blue;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="color: black;">Now we have to create an Adapeter for the ListView this is jest a <span style="background-color: yellow;">new Java</span> file (known as class file). To create this Right click on your package file named "</span></span></span></span></span></span><span style="background-color: yellow;">com.arise.customlanguagelistview"<span style="background-color: white;"> clcik "<span style="background-color: yellow;">New</span>" and then "<span style="background-color: yellow;">Class</span>" as shown in the picture.</span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><br /></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-15JlR41iEjM/URvGZMKOOUI/AAAAAAAAAkY/6pFaR3Yhqxo/s1600/new+class.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-15JlR41iEjM/URvGZMKOOUI/AAAAAAAAAkY/6pFaR3Yhqxo/s640/new+class.jpeg" height="358" width="640" /></a></div>
<span style="background-color: yellow;"><span style="background-color: white;"><br /></span></span>
<br />
<span style="background-color: yellow;"><span style="background-color: white;"> Now give it the name"<span style="background-color: yellow;">NewAdapter</span>" as shown in the diagram and <span style="background-color: yellow;">click</span> <span style="background-color: yellow;">finish</span>.</span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><br /></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-98ZiTtHTuLs/URvIer3TeqI/AAAAAAAAAkg/fOx6MR0jwvY/s1600/Workspace+1_005.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-98ZiTtHTuLs/URvIer3TeqI/AAAAAAAAAkg/fOx6MR0jwvY/s640/Workspace+1_005.jpeg" height="358" width="640" /></a></div>
<span style="background-color: yellow;"><span style="background-color: white;"><br /></span></span>
<span style="background-color: yellow;"><span style="background-color: white;">The new Java file will be automtically opened, Now enter the following code in to the file.</span></span><br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;">The details are given as comments. </span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><br /></span></span>
<span style="background-color: yellow;"><span style="background-color: white;"><span style="color: blue;">package com.arise.customlanguagelistview;<br /><br />import java.util.ArrayList;<br /><br />import android.app.Activity;<br />import android.graphics.Color;<br />import android.graphics.Typeface;<br />import android.view.Gravity;<br />import android.view.LayoutInflater;<br />import android.view.View;<br />import android.view.ViewGroup;<br />import android.view.View.OnClickListener;<br />import android.widget.BaseExpandableListAdapter;<br />import android.widget.CheckedTextView;<br />import android.widget.TextView;<br />import android.widget.Toast;<br /><br />@SuppressWarnings("unchecked")<br />public class NewAdapter extends BaseExpandableListAdapter {<br /> <br /> public ArrayList<String> groupItem, tempChild;<br /> public ArrayList<Object> Childtem = new ArrayList<Object>();<br /> public LayoutInflater minflater;<br /> public Activity activity;<br /> <br /><br /> public NewAdapter(ArrayList<String> grList, ArrayList<Object> childItem) {<br /> groupItem = grList;<br /> this.Childtem = childItem;<br /> }<br /><br /> public void setInflater(LayoutInflater mInflater, Activity act) {<br /> this.minflater = mInflater;<br /> activity = act;<br /> }<br /><br /> @Override<br /> public Object getChild(int groupPosition, int childPosition) {<br /> return null;<br /> }<br /><br /> @Override<br /> public long getChildId(int groupPosition, int childPosition) {<br /> return 0;<br /> }<br /> <br /> <br /> @Override <br /> public View getChildView(final int groupPosition, final int childPosition,<br /> boolean isLastChild, View convertView, ViewGroup parent) {<br /> tempChild = (ArrayList<String>) Childtem.get(groupPosition);<br /> TextView text = null;<br /> if (convertView == null) {<br /> convertView = minflater.inflate(R.layout.child, null);<br /> }<br /> text = (TextView) convertView.findViewById(R.id.textView1);<br /> //To set a custom language font, first save the font file in asset folder.<br /> //You may create a folder named "fonts"inside asset folder and save the font file inside it<br /> //Now we have to set the Type face to the Text View as follows<br /> Typeface typeFace = Typeface.createFromAsset(convertView.getContext().getAssets(),"fonts/AnjaliOldLipi.ttf");<br /> text.setTypeface(typeFace);<br /> <br /> <br /> if (groupPosition==0 && childPosition== 0)//For setting a different color to the list Item 1 under Heading,Date <br /> //Please note that Group(Heading) Item and Child (list)Item starts with 0, instead of 1<br /> {<br /> ((TextView) text).setTextColor(Color.RED); //Giving Android default color red <br /> //instead of taking color value from string<br /> }<br /> <br /> <br /> else if (groupPosition==1 && childPosition== 1)//Use only "else if' for next item <br /> {<br /> ((TextView) text).setTextColor(Color.RED); <br /> }<br /> <br /> <br /> <br /> else //For setting a color to rest all item<br /> {<br /> ((TextView) text).setTextColor(convertView.getContext().getResources().getColor(R.color.steel_blue)); <br /> }<br /> <br /> <br /> text.setText(tempChild.get(childPosition));<br /> convertView.setOnClickListener(new OnClickListener() {<br /> @Override<br /> public void onClick(View v) {<br /> Toast.makeText(activity, tempChild.get(childPosition),<br /> Toast.LENGTH_SHORT).show();<br /> }<br /> });<br /> return convertView;<br /> }<br /> <br /> @Override<br /> public int getChildrenCount(int groupPosition) {<br /> return ((ArrayList<String>) Childtem.get(groupPosition)).size();<br /> }<br /><br /> @Override<br /> public Object getGroup(int groupPosition) {<br /> return null;<br /> }<br /><br /> @Override<br /> public int getGroupCount() {<br /> return groupItem.size();<br /> }<br /><br /> @Override<br /> public void onGroupCollapsed(int groupPosition) {<br /> super.onGroupCollapsed(groupPosition);<br /> }<br /><br /> @Override<br /> public void onGroupExpanded(int groupPosition) {<br /> super.onGroupExpanded(groupPosition);<br /> }<br /><br /> @Override<br /> public long getGroupId(int groupPosition) {<br /> return 0;<br /> }<br /><br /> @Override<br /> public View getGroupView(int groupPosition, boolean isExpanded,<br /> View convertView, ViewGroup parent) {<br /> if (convertView == null) {<br /> convertView = minflater.inflate(R.layout.activity_list_view_main, null);<br /> }<br /> Typeface typeFace = Typeface.createFromAsset(convertView.getContext().getAssets(),"fonts/AnjaliOldLipi.ttf");<br /> ((CheckedTextView) convertView).setTypeface(typeFace);<br /> <br /> if (groupPosition==0 )<br /> //For setting a heading on the center and giving it a color<br /> {<br /> ((CheckedTextView) convertView).setTextColor(convertView.getContext().getResources().getColor(R.color.steel_blue));<br /> ((CheckedTextView) convertView).setGravity(Gravity.CENTER);<br /> }<br /> <br /> else <br /> // For Setting all other Headings on the Left and giving rest of all a different color<br /> {<br /> ((CheckedTextView) convertView).setTextColor(convertView.getContext().getResources().getColor(R.color.orange));<br /> ((CheckedTextView) convertView).setGravity(Gravity.LEFT);<br /> }<br /> <br /> ((CheckedTextView) convertView).setText(groupItem.get(groupPosition));<br /> ((CheckedTextView) convertView).setChecked(isExpanded);<br /> return convertView;<br /> }<br /><br /> @Override<br /> public boolean hasStableIds() {<br /> return false;<br /> }<br /><br /> @Override<br /> public boolean isChildSelectable(int groupPosition, int childPosition) {<br /> return false;<br /> }<br /><br />}</span></span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><br /></span></span>
<span style="background-color: yellow;"><span style="background-color: white;"> In this file we assign the ArrayList headings and Items added in the Main Java file to the TextView.</span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><br /></span></span>
<br />
<span style="background-color: yellow;"><span style="background-color: white;"> Since I am going to display the Local Language </span></span><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">text </span></span>(or custom Font) download the font for your language (Just search in Google for it) and copy the font in to the "assets" folder in your project as follows. For easy identification I <span style="background-color: yellow;">created</span> an inner folder named "<span style="background-color: yellow;">fonts</span>" <span style="background-color: yellow;">inside the assets folder</span> and <span style="background-color: yellow;">saved the font file in to it</span>.</span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;">I have used a malayalam font named "AnjaliOldLipi" see the picture below for details.</span></span><br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-J7idG0k6RWU/URu7NoKLkMI/AAAAAAAAAkE/luOYDNUVVKE/s1600/Workspace+1_001.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-J7idG0k6RWU/URu7NoKLkMI/AAAAAAAAAkE/luOYDNUVVKE/s640/Workspace+1_001.jpeg" height="358" width="640" /></a></div>
<br />
<br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;">But if you want to display items in English the following codes are not required, it will work even though you do not delete it.</span></span><br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="color: blue;">Typeface typeFace = Typeface.createFromAsset(convertView.getContext().getAssets(),"fonts/AnjaliOldLipi.ttf");<br /> ((CheckedTextView) convertView).setTypeface(typeFace);</span> </span></span><br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;"> Now we have to create an XML file for the ListItems. </span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;">Right Click on the layout file (</span></span><span style="background-color: yellow;">CustomLanguageListView > res > layout > <span style="background-color: white;"> ) and click "<span style="background-color: yellow;">New</span>" and "New <span style="background-color: yellow;">Android XML File</span>" as shown in the picture below.</span></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-ISgeM5WnDzU/URvRol6DozI/AAAAAAAAAk0/M9QpZmcImF4/s1600/Workspace+1_007.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-ISgeM5WnDzU/URvRol6DozI/AAAAAAAAAk0/M9QpZmcImF4/s640/Workspace+1_007.jpeg" height="358" width="640" /></a></div>
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><br /></span></span>
<span style="background-color: yellow;"><span style="background-color: white;">Now <span style="background-color: yellow;">give</span> <span style="background-color: yellow;">name</span> as "<span style="background-color: yellow;">child</span>" to the XML file as shown in the picture below, and click finish to create the file.</span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><br /></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-SGZtShBpeYo/URvSEnRz2nI/AAAAAAAAAk8/msT78QhngOY/s1600/Workspace+1_008.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-SGZtShBpeYo/URvSEnRz2nI/AAAAAAAAAk8/msT78QhngOY/s640/Workspace+1_008.jpeg" height="358" width="640" /></a></div>
<span style="background-color: yellow;"><span style="background-color: white;"><br /></span></span>
<br />
Now copy the following code in to the new XML file,<br />
<span style="color: blue;"><br /></span>
<span style="color: blue;"><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br /> xmlns:tools="http://schemas.android.com/tools"<br /> android:layout_width="match_parent" <br /> android:layout_height="match_parent" <br /> android:background="@android:color/transparent" <br /> android:clickable="true"<br /> android:orientation="vertical"<br /> <br /> tools:context=".MainActivity" ><br /><br /> <LinearLayout<br /> android:layout_width="match_parent"<br /> android:layout_height="match_parent"<br /> android:gravity="center_vertical"><br /> <br /> <TextView<br /> android:id="@+id/textView1"<br /> android:layout_width="fill_parent"<br /> android:layout_height="wrap_content"<br /> android:layout_marginTop="4dp"<br /> android:gravity="center_vertical"<br /> android:layout_marginLeft="5dp"<br /> android:text="@string/hello_world"<br /> android:textColor="@color/steel_blue"<br /> android:textSize="15sp"<br /> android:textStyle="bold" /><br /> </LinearLayout> <br /><br /></LinearLayout></span><br />
<br />
Here we are creating a <span style="background-color: yellow;">TextView</span> inside a <span style="background-color: yellow;">LinearLayout</span>. The color of the text is given as blue, which is to be declared in the strings.XML file later.<br />
Ignore the errors shown.<br />
<br />
Now we have to create a <span style="background-color: yellow;">selector file</span> inside a<span style="background-color: yellow;"> new folder</span> named "<span style="background-color: yellow;">drawable</span>"<br />
for that <span style="background-color: yellow;">Right click</span> on the "<span style="background-color: yellow;">res</span>" <span style="background-color: yellow;">folder</span> and click "<span style="background-color: yellow;">new</span>" and click "<span style="background-color: yellow;">folder</span>"<br />
as shown in the picture below.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-rIkzK2M54RQ/URvUi0fxBTI/AAAAAAAAAlE/Bm2BM431ygM/s1600/Workspace+1_009.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-rIkzK2M54RQ/URvUi0fxBTI/AAAAAAAAAlE/Bm2BM431ygM/s640/Workspace+1_009.jpeg" height="358" width="640" /></a></div>
<br />
<span style="background-color: yellow;">Give</span> the folder <span style="background-color: yellow;">name</span> as "<span style="background-color: yellow;">drawable</span>" and click "<span style="background-color: yellow;">Finish</span>" to create the folder, as shown in the picture below.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-7jnRfX4pYoU/URvWpp5pLDI/AAAAAAAAAlQ/L2z7oreg5yo/s1600/Workspace+1_010.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-7jnRfX4pYoU/URvWpp5pLDI/AAAAAAAAAlQ/L2z7oreg5yo/s640/Workspace+1_010.jpeg" height="358" width="640" /></a></div>
<span style="background-color: yellow;">Right click</span> on the newly created "<span style="background-color: yellow;">drawable</span>" folder and click "<span style="background-color: yellow;">New</span>" click "<span style="background-color: yellow;">Android XML File</span>" and Give the <span style="background-color: yellow;">name</span> "<span style="background-color: yellow;">iconselector</span>" to the file. Choose the root element as "<span style="background-color: yellow;">selector</span>" and click finish as shown in the picture below.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-EiECZOA5Flk/URvZXpxM0wI/AAAAAAAAAlg/GrgyxYBPQfU/s1600/Workspace+1_011.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-EiECZOA5Flk/URvZXpxM0wI/AAAAAAAAAlg/GrgyxYBPQfU/s640/Workspace+1_011.jpeg" height="358" width="640" /></a></div>
<br />
Now copy the following code in to the new file.<br />
<br />
<span style="color: blue;"><?xml version="1.0" encoding="utf-8"?><br /><selector xmlns:android="http://schemas.android.com/apk/res/android" ><br /> <item android:drawable="@drawable/up" android:state_checked="true"></item><br /> <item android:drawable="@drawable/down"></item><br /></selector></span><br />
Here we are specifying an<span style="background-color: yellow;"> icon </span>named "<span style="background-color: yellow;">up</span>" from the drawable image folders, which is to be shown when the List is in <span style="background-color: yellow;">expanded position</span> and another icon named "<span style="background-color: yellow;">down</span>" when the List is in the <span style="background-color: yellow;">collapsed position</span>.<br />
<br />
Save the file and close it.<br />
<br />
Now we have to sepcify the color names in the strings.XML file.<br />
Open file <span style="background-color: yellow;">CustomLanguageListView > res > values > strings.xml</span><br />
<br />
Copy the following code in to the file,<br />
<br />
<span style="color: blue;"><?xml version="1.0" encoding="utf-8"?><br /><resources><br /><br /> <string name="app_name">CustomLanguageListView</string><br /> <string name="hello_world">Hello world!</string><br /> <string name="menu_settings">Settings</string><br /> <color name="steel_blue">#488AC7</color><br /> <color name="orange">#F88017</color> <br /> <br /></resources></span><br />
<br />
The <span style="background-color: yellow;">color names </span>and the corresponding <span style="background-color: yellow;">color codes</span> are given here. You can use html color codes in Android and give any name as you like. To get color code search "html color codes" in Google.<br />
<br />
Lastly we have to save "up" and "down" arrow icons in to the drawable pictures folder. You can get the Android icons pack from the Google Developer site from the <a href="http://developer.android.com/design/downloads/index.html" target="_blank">link here</a>. Or you may choose any small icons as you want.<br />
<br />
To choose an icon in an easy way open your Android manifest File<br />
<span style="background-color: yellow;">CustomLanguageListView > AndroidManifest.xml </span><br />
<span style="background-color: yellow;"><span style="background-color: white;">Now choose the <span style="background-color: yellow;">application tab</span> and click "<span style="background-color: yellow;">browse</span>" button next to the "<span style="background-color: yellow;">icon</span>"</span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;">This is actually intended to change the icon of the application but you can create an icon using this method.</span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;">see the image for details,</span></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-wSo-yos1Ez0/URvfEvxcpdI/AAAAAAAAAl0/yaWj-dp-z3A/s1600/Workspace+1_012.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-wSo-yos1Ez0/URvfEvxcpdI/AAAAAAAAAl0/yaWj-dp-z3A/s640/Workspace+1_012.jpeg" height="358" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="background-color: yellow;"><span style="background-color: white;"> In the next child window select "<span style="background-color: yellow;">Create New Icon</span>"</span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><br /></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-KdC9w0PcdEE/URvvFI6_FRI/AAAAAAAAAmI/jtRP6CbPsLs/s1600/Workspace+1_013.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-KdC9w0PcdEE/URvvFI6_FRI/AAAAAAAAAmI/jtRP6CbPsLs/s640/Workspace+1_013.jpeg" height="358" width="640" /></a></div>
<span style="background-color: yellow;"><span style="background-color: white;"><br /></span></span>
<span style="background-color: yellow;"><span style="background-color: white;">In the next child window select "<span style="background-color: yellow;">Notification icon</span>" and give the name as "<span style="background-color: yellow;">up</span>" and click next</span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><br /></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-R-03qu4Wsic/URvvaQ1jnYI/AAAAAAAAAmQ/US9iCdlvyoo/s1600/Create+Asset+Set+_014.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-R-03qu4Wsic/URvvaQ1jnYI/AAAAAAAAAmQ/US9iCdlvyoo/s320/Create+Asset+Set+_014.jpeg" height="311" width="320" /></a></div>
<br />
<span style="background-color: yellow;"><span style="background-color: white;">In the next Child window Click image and click "browse" and choose an icon.</span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;">If you have downloaded the font pack from google then choose </span></span><br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;">All_icons > Holo dark > xhdpi > 1_navigation_collapse</span> </span></span><br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;">Click finish and cancel the <span style="background-color: yellow;">Resource Chooser</span></span></span><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-c3Y_Ujp4YYE/URvv5JY7f5I/AAAAAAAAAmY/UUTZYP9vX2k/s1600/Create+Asset+Set+_015.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-c3Y_Ujp4YYE/URvv5JY7f5I/AAAAAAAAAmY/UUTZYP9vX2k/s320/Create+Asset+Set+_015.jpeg" height="311" width="320" /></a></div>
<br />
Follow the same step above to create an "down" arrow icon<br />
choose the following file<br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;">All_icons > Holo dark > xhdpi >1_navigation_expand </span></span></span><br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: yellow;"><span style="background-color: white;">Click finish and cancel the <span style="background-color: yellow;">Resource Chooser</span></span></span></span></span></span><br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"> Lastly add the following lines (highligted in blue) to your Android manifest file for Holo Black theme, (see the picture below for details)</span></span></span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"><br /></span></span></span></span>
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="color: red;"> <activity</span><br /> <span style="background-color: #6fa8dc;"> android:theme="@android:style/Theme"</span><br /> <span style="color: red;"> android:name="com.arise.customlanguagelistview.ListViewMainActivity"<br /> android:label="@string/app_name" ><br /> <intent-filter><br /> <action android:name="android.intent.action.MAIN" /> </span></span></span></span></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-lOVq8DqiIig/URwaO1k43HI/AAAAAAAAAm8/r18AJFPLMmA/s1600/Workspace+1_016.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-lOVq8DqiIig/URwaO1k43HI/AAAAAAAAAm8/r18AJFPLMmA/s640/Workspace+1_016.jpeg" height="358" width="640" /></a></div>
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"> </span> </span></span></span><br />
<br />
Now the project is ready to run.<br />
When you run the project you will see the following result.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-BgkHBjTmeGs/URvyL7m2YJI/AAAAAAAAAmg/mMOSRI0gZwQ/s1600/5554:smart_014.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-BgkHBjTmeGs/URvyL7m2YJI/AAAAAAAAAmg/mMOSRI0gZwQ/s320/5554:smart_014.png" height="320" width="261" /></a></div>
<br />
When you click on the heading the List Item is displayed as shown in the image shown below,<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-WTYXVpmFMjs/URvyeZDuBhI/AAAAAAAAAmo/qqcs8cuxGUY/s1600/5554:smart_015.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-WTYXVpmFMjs/URvyeZDuBhI/AAAAAAAAAmo/qqcs8cuxGUY/s320/5554:smart_015.png" height="320" width="261" /></a></div>
<br />
<br />
<br />
<br />
<br />
Now you have successfully completed a ListView Project.<br />
<span style="background-color: lime;">You may download the source file from<span style="color: black;"> </span><span style="background-color: white;"> <span style="color: blue;"><a href="https://www.dropbox.com/s/fkh736mvozy7650/CustomLanguageListView.zip?dl=0" target="_blank">This Link</a></span></span></span><br />
<br />
<br />Arise Rayamangalamhttp://www.blogger.com/profile/17522192478676631711noreply@blogger.com49tag:blogger.com,1999:blog-9176720325012787290.post-1716946339500355092013-02-03T01:58:00.002-08:002013-02-12T00:22:30.345-08:0010. How to display local Language Text with custom font in AndroidFor displaying the Languages which are not supported by Android, we have to pack the font for the language along with our application package.<br />
<br />
First Download the required font for your language (To find one just Google it) I have used Malayalam font here (<cite><a href="https://sites.google.com/site/fontpacksite/malayalam-fonts" target="_blank">https://sites.google.com/site/fontpacksite/malayalam-fonts</a><b><span id="goog_2052924077"></span><span id="goog_2052924078"></span></b>)<b>.</b></cite>Then we have to copy a suitable font for your language in to the "asset" folder. For example I have used the font named "AnjaliOldLipi" for "Malayalam" .<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-m6l3RtlMH5s/UQ4yztD1lTI/AAAAAAAAAdQ/VfcIrtgz7Jo/s1600/1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="452" src="http://2.bp.blogspot.com/-m6l3RtlMH5s/UQ4yztD1lTI/AAAAAAAAAdQ/VfcIrtgz7Jo/s640/1.jpg" width="640" /></a></div>
<br />
Now If you want to display it in to a TextView the format is as shown below, since I have saved the font inside a new folder named "fonts" I have to give "fonts/.......,ttf"<br />
<br />
<span style="color: blue;">TextView tv = (TextView)findViewById(R.id.textView1);<br /> Typeface typeFace = Typeface.createFromAsset(getAssets(),"fonts/AnjaliOldLipi.ttf");<br /> tv.setTypeface(typeFace);<br /> tv.setText("മലയാളം"); </span><br />
<br />
Now it will show the corresponding text in to the TextView in your language. When you run the program or export an APK file, this font will be packed along with the APK file, so the font will work in any Android device, which do not have this font installed.Arise Rayamangalamhttp://www.blogger.com/profile/17522192478676631711noreply@blogger.com16tag:blogger.com,1999:blog-9176720325012787290.post-84115142246918768362013-02-02T12:32:00.002-08:002013-02-28T13:04:21.890-08:009.How to write and read from a text file in AndroidToday we are going to learn how to read and write from a text file(Sorce file download link given at the end). The <span style="background-color: yellow;">text file</span> can be <span style="background-color: yellow;">created</span> <span style="background-color: yellow;">in</span> the <span style="background-color: yellow;">internal memory or external memory</span> (SD Card).<br />
<span style="background-color: lime;">(TIP)</span> but you cannot write in to a file which is in the application directory like asset folder, since all application files will be read only when the application is run.<br />
<br />
Now we want an <span style="background-color: yellow;">Edit Text</span>, a <span style="background-color: yellow;">TextView</span> and <span style="background-color: yellow;">two buttons</span> for this activity. What we enter in EditText will be saved when clicking a button "Save" and will be read and displayed in TextView when we click "ViewText" button.<br />
<br />
So the Activity_Main XML file will be looked as follows.<br />
<br />
<span style="color: blue;"><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"<br /> xmlns:tools="http://schemas.android.com/tools"<br /> android:layout_width="match_parent"<br /> android:layout_height="match_parent"<br /> tools:context=".MainActivity" ><br /><br /> <br /> <EditText<br /> android:id="@+id/editText1"<br /> android:layout_width="wrap_content"<br /> android:layout_height="wrap_content" <br /> android:layout_centerHorizontal="true"<br /> android:layout_marginTop="20dp"<br /> android:ems="10"<br /> android:inputType="textPostalAddress" ><br /><br /> <requestFocus /><br /> </EditText><br /><br /> <TextView<br /> android:id="@+id/textView1"<br /> android:layout_width="wrap_content"<br /> android:layout_height="wrap_content" <br /> android:layout_below="@+id/editText1"<br /> android:layout_centerHorizontal="true" <br /> android:text="TextView" /><br /> <br /> <LinearLayout <br /> android:layout_width="fill_parent"<br /> android:layout_height="wrap_content"<br /> android:layout_alignParentBottom="true"<br /> android:layout_marginBottom="30dp"<br /> android:gravity="center"><br /><br /> <Button<br /> android:id="@+id/button1"<br /> android:layout_width="wrap_content"<br /> android:layout_height="wrap_content" <br /> android:onClick="SaveText"<br /> android:text="Save" /><br /><br /> <Button<br /> android:id="@+id/button2"<br /> android:layout_marginLeft="20dp"<br /> android:layout_width="wrap_content"<br /> android:layout_height="wrap_content" <br /> android:onClick="ViewText"<br /> android:text="View" /><br /> <br /> </LinearLayout><br /></RelativeLayout></span><br />
<br />
<span style="background-color: lime;">(TIP)</span> I have created the two buttons inside a LinearLayout and given the gravity as center. So that both the buttons will be automatically aligned center. On the second button I have given a margin to the left side so that it will be separated from the first button by 20dp.<br />
<br />
When the button1 (will be displayed as "view" button since the button text is view) is clicked a method <span style="background-color: yellow;">"SaveText"</span> will be <span style="background-color: yellow;">called</span> to <span style="background-color: yellow;">save the text</span> in to a file. ( that is why we have given here onClick="SaveText") This "SaveText" method will be written in MainActivity.java as you can see below. Similarly <span style="background-color: yellow;">"ViewText"</span> method also will be written there <span style="background-color: yellow;">to view the text</span> saved in the file. <br />
the MainActivity.java will be as follows.<br />
<br />
for easy to understand I have given all the activities as comments (anything start with "//" is a comment) <br />
<br />
<span style="color: #38761d;">package com.arise.filewritereader;<br />import java.io.BufferedReader;<br />import java.io.IOException;<br />import java.io.InputStream;<br />import java.io.InputStreamReader;<br />import java.io.OutputStreamWriter;<br />import android.os.Bundle;<br />import android.app.Activity;<br />import android.view.Menu;<br />import android.view.View;<br />import android.widget.EditText;<br />import android.widget.TextView;<br />import android.widget.Toast;<br /><br />public class MainActivity extends Activity {<br /><br /> @Override<br /> protected void onCreate(Bundle savedInstanceState) {<br /> super.onCreate(savedInstanceState);<br /> setContentView(R.layout.activity_main);<br /> }</span><br />
<br />
<span style="color: #990000;"><span style="background-color: cyan;"> public void SaveText(View view)</span>{ <br /> <br /> try {</span><br />
<span style="color: #990000;"><br /> // open myfilename.txt for writing<br /> OutputStreamWriter out=newOutputStreamWriter(openFileOutput("myfilename.txt",MODE_APPEND));<br /> // write the contents to the file</span><br />
<span style="color: #990000;"><br /> EditText ET = (EditText)findViewById(R.id.editText1);<br /> String text = ET.getText().toString();<br /> out.write(text);<br /> out.write('\n'); </span><br />
<span style="color: #990000;"> <br /> // close the file</span><br />
<span style="color: #990000;"><br /> out.close();</span><br />
<span style="color: #990000;"><br /> Toast.makeText(this,"Text Saved !",Toast.LENGTH_LONG).show();<br /> } </span><br />
<br />
<span style="color: #990000;">catch (java.io.IOException e) {</span><br />
<span style="color: #990000;"><br /> //do something if an IOException occurs.</span><br />
<span style="color: #990000;">Toast.makeText(this,"Sorry Text could't be added",Toast.LENGTH_LONG).show();</span><br />
<span style="color: #990000;"></span><br />
<span style="color: #990000;"><br /> }<br /> <br /> }</span><br />
<br />
<span style="color: blue;"> <span style="background-color: cyan;">public void ViewText (View view)</span>{ <br /> <br /> StringBuilder text = new StringBuilder();<br /> <br /> <br /> try {<br /> // open the file for reading we have to surround it with a try<br /> <br /> InputStream instream = openFileInput("myfilename.txt");//open the text file for reading<br /> <br /> // if file the available for reading<br /> if (instream != null) { <br /> <br /> // prepare the file for reading<br /> InputStreamReader inputreader = new InputStreamReader(instream);<br /> BufferedReader buffreader = new BufferedReader(inputreader);<br /> <br /> String line=null;<br /> //We initialize a string "line" <br /> <br /> while (( line = buffreader.readLine()) != null) {<br /> //buffered reader reads only one line at a time, hence we give a while loop to read all till the text is null<br /> <br /> text.append(line); <br /> text.append('\n'); //to display the text in text line <br /> <br /> <br /> }}} <br /> <br /> //now we have to surround it with a catch statement for exceptions<br /> catch (IOException e) {<br /> e.printStackTrace();<br /> }<br /> <br /> //now we assign the text readed to the textview<br /> TextView tv = (TextView)findViewById(R.id.textView1); <br /> tv.setText(text); <br /> <br /> }</span><br />
<br />
<br />
<span style="color: #38761d;"> @Override<br /> public boolean onCreateOptionsMenu(Menu menu) {<br /> // Inflate the menu; this adds items to the action bar if it is present.<br /> getMenuInflater().inflate(R.menu.activity_main, menu);<br /> return true;<br /> }<br /><br />}</span><br />
<br />
<br />
what we are doing is when first button (named "Save") is clicked first method ie. "SaveText" will be called. I have highlighted it as red. <span style="color: #990000;"><span style="background-color: yellow;">OutputStreamWriter</span> <span style="color: black;">is used <span style="background-color: yellow;">to write in to file</span>. The file named </span><span style="background-color: yellow;">"</span></span><span style="color: #990000;"><span style="background-color: yellow;">myfilename.txt"</span> <span style="color: black;">will be automatically created in the internal phone memory when it is called for writing. Here we give</span> <span style="background-color: yellow;">"MODE_APPEND</span></span><span style="background-color: yellow;">"</span> so that what ever the text added in to the file will be <span style="background-color: yellow;">appended</span> in <span style="background-color: yellow;">to</span> the <span style="background-color: yellow;">existing one</span>. If "0" is given instead of <span style="color: #990000;">"MODE_APPEND</span>" it will re write all the data in the file.<br />
<br />
Now we find the <span style="background-color: yellow;">EditText1</span> as given in the XML file and give it a name <span style="background-color: yellow;">"ET"</span> then <span style="color: #990000;"><span style="color: black;">we create a <span style="background-color: yellow;">string</span> called </span><span style="background-color: yellow;">"text</span></span><span style="background-color: yellow;">" </span>and save what ever you enter in the <span style="background-color: yellow;">EditText in to it. </span>Now we write the contents saved in the String named "text" in the file using a command <span style="background-color: yellow;"><span style="color: #990000;">"out.write</span>()"</span>. Since it is append mode, it will write the text you enter next time in to the same line with out any space or comma. So we use <span style="color: #990000;"><span style="background-color: yellow;">out.write('\n');</span> <span style="color: black;"><span style="background-color: yellow;">so that </span>next line will be saved <span style="background-color: yellow;">below the first</span> line.</span></span> Then we <span style="background-color: yellow;">close</span> the<span style="background-color: yellow;"> file</span>, toast something and surround it with a <span style="background-color: yellow;">catch statemen</span>t to handle <span style="background-color: yellow;">exceptions.</span><br />
<br />
When the <span style="background-color: yellow;">"View" button</span> is clicked the <span style="background-color: yellow;">second method</span> is executed. I have given it as blue. We will open the same file for reading and read the content with a <span style="color: blue;"> <span style="background-color: yellow;">BufferedReader.</span> <span style="color: black;">But it can only <span style="background-color: yellow;">read one line at a time</span>. So we give a <span style="background-color: yellow;">while loop </span>to read all lines <span style="background-color: yellow;">till the line is null</span>.</span></span> The readed line will be stored in a <span style="background-color: yellow;">String</span> called<span style="background-color: white;"> "line" </span>and it will be appended to a <span style="background-color: yellow;">StringBuilder</span> called "text" which was initialised just after calling method.<br />
<br />
<br />
Now we find the <span style="background-color: yellow;">TextView</span> in the XML file and give it a name <span style="background-color: yellow;">"tv"</span> and the <span style="background-color: yellow;">"text"</span> will be <span style="background-color: yellow;">set in to</span> the TextView.<br />
<br />
<br />
When we run the emulator we can<span style="background-color: white;"> write</span> something in the EditText and click the <span style="background-color: yellow;">"Save"</span> button <span style="background-color: yellow;">to write</span> in to the file as follows.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-YLQ4HIwc2ko/UQ10Bg8petI/AAAAAAAAAc8/6NkZm4cQ7zI/s1600/5554:smart_003.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://2.bp.blogspot.com/-YLQ4HIwc2ko/UQ10Bg8petI/AAAAAAAAAc8/6NkZm4cQ7zI/s320/5554:smart_003.png" width="261" /></a></div>
<br />
<br />
Now when we click the<span style="background-color: yellow;"> "View"</span> button, the text saved in the file will be read and <span style="background-color: yellow;">shown</span> in to the TextView as follows.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-YLQ4HIwc2ko/UQ10Bg8petI/AAAAAAAAAc8/6NkZm4cQ7zI/s1600/5554:smart_003.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://2.bp.blogspot.com/-YLQ4HIwc2ko/UQ10Bg8petI/AAAAAAAAAc8/6NkZm4cQ7zI/s320/5554:smart_003.png" width="261" /></a></div>
So, Today we have learned how to write and read from a Text File. Thank you for reading.<br />
<b><span style="background-color: lime;">(TIP)</span><span style="background-color: lime;"> </span></b><span style="background-color: lime;">You may download the full source file from<span style="background-color: white;"><b> <a href="http://rapidshare.com/files/3997109151/FileWriteReader.zip" target="_blank">here. </a></b></span></span>Arise Rayamangalamhttp://www.blogger.com/profile/17522192478676631711noreply@blogger.com25tag:blogger.com,1999:blog-9176720325012787290.post-79106678677639915052013-01-14T04:05:00.003-08:002013-02-07T19:18:48.776-08:008. How to easily rename your package file in Android So if you have forgotten to rename your application package name during the project creation. As default Android give the name as "com.example", which is not accepted, if you publish it in Google Play. So you have to change your package name. It is very easy to do that.<br />
Just <span style="background-color: yellow;">right clcik</span> on the <span style="background-color: yellow;">project folder</span> eg.sample, and and select <span style="background-color: yellow;">"Android Tools"</span> from the popup menu, now select <span style="background-color: yellow;"> "rename application package"</span> as shown in the picture below.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-OaY_S7pDTUw/UPPw03pME-I/AAAAAAAAAaU/r09B3jlkFGY/s1600/screen29.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://1.bp.blogspot.com/-OaY_S7pDTUw/UPPw03pME-I/AAAAAAAAAaU/r09B3jlkFGY/s640/screen29.png" width="640" /></a></div>
<br />
Now a <span style="background-color: white;">child window</span> named<span style="background-color: white;"> "Rename application package"</span> is opened.<span style="background-color: yellow;"> click</span> on the <span style="background-color: yellow;">old package name</span> to rename and <span style="background-color: yellow;">type a new name</span>. eg: replace "example" with new name "arise" as shown in the picture below.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-ecYI3naKyHM/UPPx6JArjmI/AAAAAAAAAag/p3twbzXFRdY/s1600/screen30.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://1.bp.blogspot.com/-ecYI3naKyHM/UPPx6JArjmI/AAAAAAAAAag/p3twbzXFRdY/s640/screen30.png" width="640" /></a></div>
<br />
Now another window named <span style="background-color: yellow;">"Refactoring"</span> is appeared. Don't change anything, Just <span style="background-color: yellow;">click finish</span>.as shown below.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-ehOBi_4QD8Q/UPPyo9OMFAI/AAAAAAAAAaw/yh5My1IbQy4/s1600/screen31.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://4.bp.blogspot.com/-ehOBi_4QD8Q/UPPyo9OMFAI/AAAAAAAAAaw/yh5My1IbQy4/s640/screen31.png" width="640" /></a></div>
<br />
Now a message window named "Launch configuration update" is shown. Just click <span style="background-color: yellow;">"YES"</span> as shown below.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-dZohnobSZz0/UPPzTpEtiPI/AAAAAAAAAbE/oJdXzetKHHA/s1600/screen32.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://1.bp.blogspot.com/-dZohnobSZz0/UPPzTpEtiPI/AAAAAAAAAbE/oJdXzetKHHA/s640/screen32.png" width="640" /></a></div>
<br />
Now you have successfully renamed your package. open the "gen" and "android manifest" to see the changed name. <span style="background-color: lime;">(TIP) </span>The package name in "src" will not be renamed. Its not a problem. (See the image below)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-ZXXWmsNNly8/UPP0M6pYU6I/AAAAAAAAAbQ/Ir8E-0v0DBA/s1600/screen33.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://4.bp.blogspot.com/-ZXXWmsNNly8/UPP0M6pYU6I/AAAAAAAAAbQ/Ir8E-0v0DBA/s640/screen33.png" width="640" /></a></div>
<br />
<br />Arise Rayamangalamhttp://www.blogger.com/profile/17522192478676631711noreply@blogger.com1tag:blogger.com,1999:blog-9176720325012787290.post-2778409342184436272013-01-14T03:08:00.001-08:002013-02-07T19:21:48.670-08:007. XML format for EditText and EditText parameters<h3>
<span style="font-weight: normal;">1. EditText Format in XML</span></h3>
<span style="font-weight: normal;"> <span style="color: blue;"> <b><EditText</b></span><b><br style="color: blue;" /><span style="color: blue;"> android:id="@+id/editText1"</span></b></span><br />
<span style="font-weight: normal;"><b><span style="color: blue;"> <requestFocus /></span><br style="color: blue;" /><span style="color: blue;"> </EditText></span></b> </span><br />
<h3>
<span style="font-weight: normal;"> 2.</span><u><b>Important EditText Parameters</b></u></h3>
<br />
<div style="color: #cc0000;">
<b> <span style="color: blue;">android:layout_width="wrap_content"</span></b><span style="color: black;"> </span></div>
<div style="color: #cc0000;">
<span style="color: black;"> (restrict the width of the layout to the content width, eg. width of text)</span></div>
<div style="color: #cc0000;">
</div>
<div style="color: blue;">
<b> android:layout_width="match_parent" </b></div>
<div style="color: #cc0000;">
<b> </b><span style="background-color: white; color: black;">(extend the width to the parent width.eg.fill the screen width</span><span style="color: black;">)</span></div>
<div style="color: #cc0000;">
</div>
<div style="color: blue;">
<b> android:layout_height="wrap_content" </b> </div>
<div style="color: #cc0000;">
<span style="color: black;"> (restrict the height of the layout to the content height. eg. height of text)</span></div>
<div style="color: #cc0000;">
</div>
<div style="color: blue;">
<b> android:layout_height="match_parent"</b><b> </b></div>
<div style="color: #cc0000;">
<b> </b><span style="background-color: white; color: black;">(extend the height to the parent height</span><span style="color: black;">.eg. fill the screen height)</span></div>
<br />
<div style="color: blue; text-align: left;">
<b> </b></div>
<div style="text-align: left;">
<b><span style="color: red;"> <span style="color: blue;"> android:hint="@string/hint1"</span></span></b></div>
<div style="text-align: left;">
<div style="text-align: center;">
(Display a text when the field is empty. Will automatically
disappear when a text is entered. The hint text is storedin a string
called " hint1", string is to be specified in the "strings.xml' file in
the<br />
folder named "values as follows)</div>
<div style="text-align: left;">
<span style="color: lime;"> </span><span style="color: blue;"><string name="hint1">your text here</string></span></div>
</div>
<div style="text-align: left;">
<b style="color: #cc0000;"> </b><br />
<b style="color: #cc0000;"> <span style="color: blue;"> android:textColor="@color/white"</span></b><span style="color: #cc0000;"> </span></div>
<div style="text-align: center;">
<span style="color: #cc0000;"><span style="color: black;"> (</span></span><span style="color: black;">Apply the color stored in the string"</span><span style="color: black;">white</span><span style="color: black;">". string is to be specified in the "strings.xml in the folder </span><span style="color: black;">named </span><span style="color: black;"> "values" as follows)</span></div>
<div style="text-align: left;">
<b style="color: #cc0000;"> </b><span style="color: #cc0000;"> <span style="color: blue;"> <color name="white">#FFFFFF</color></span></span></div>
<div style="text-align: left;">
<b style="color: #cc0000;"><br /></b></div>
<div style="text-align: left;">
<b style="color: #cc0000;"> <span style="color: blue;">android:textSize="15sp"</span></b></div>
<div style="text-align: left;">
<b style="color: #cc0000;"> </b><span style="color: #cc0000;"><span style="color: black;"> (Display t</span></span><span style="color: black;">he size of the text in 15 scaled pixels, device independent)</span></div>
<div style="text-align: left;">
<br />
<b style="color: #cc0000;"> <span style="color: blue;">android:textStyle="bold"</span></b></div>
<div style="text-align: left;">
(Display the text as bold)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:typeface="serif"</b></div>
</div>
<div style="text-align: left;">
(Display the text in "serif" font)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:height="15sp"</b></div>
</div>
<div style="text-align: left;">
(Fix the height of the textview to 15sp)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:gravity="1"</b></div>
<div style="color: blue;">
<b> android:gravity="2"</b></div>
</div>
<div style="text-align: center;">
(If the gravity of item1 is "1" and of item2 is "2" both will occupy the area in the ratio 1:2, default gravity=0)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:gravity="center"</b></div>
</div>
<div style="text-align: left;">
(Display the text in the center of textview)</div>
<div style="text-align: left;">
<br />
<div style="text-align: left;">
<b> </b><br />
<div style="text-align: left;">
</div>
<div style="color: blue;">
<b> android:layout_marginLeft="20dp"</b></div>
</div>
</div>
<div style="text-align: left;">
(A space of 20dp is kept on the left side)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_marginRight="20dp"</b></div>
</div>
<div style="text-align: left;">
(A space of 20dp is kept on the right side)</div>
<div style="text-align: left;">
</div>
<div style="color: blue; text-align: left;">
<b>android:layout_marginBottom="20dp"</b> </div>
<div style="text-align: left;">
(A space of 20dp is kept on the bottom)<br />
<div style="text-align: left;">
</div>
</div>
<div style="color: blue; text-align: left;">
<b> android:layout_marginBottom="20dp"</b> </div>
<div style="text-align: left;">
(A space of 20dp is kept on the top) </div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_alignParentTop="true"</b></div>
</div>
<div style="text-align: left;">
(Position the EditText at top of the parent. eg. top of screen)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_alignParentBottom="true"</b></div>
</div>
<div style="text-align: left;">
(Position the EditText at bottom of the parent. eg. bottom of screen)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_alignParentRight="true"</b></div>
</div>
<div style="text-align: left;">
(Position the EditText at right side of the parent. eg. right side of screen)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_alignParentLeft="true"</b></div>
</div>
<div style="text-align: left;">
(Position the EditText at left side of the parent. eg. left side of screen)<br />
<b style="color: #cc0000;"> </b><br />
<div style="color: blue;">
<b> android:layout_alignBottom="@+id/button1"</b></div>
</div>
<div style="text-align: left;">
(Align the bottom of the EditText to button1)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_toRightOf="@+id/button1"</b></div>
</div>
<div style="text-align: left;">
(Align the EditText to the right of button1)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_toLeftOf="@+id/button1"</b></div>
</div>
<div style="text-align: left;">
(Align the EditText to the left of button1)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_centerHorizontal="true"</b></div>
</div>
<div style="text-align: left;">
<b style="color: #cc0000;"> </b><span style="color: black;">(Position the </span>EditText<span style="color: black;"> in Center Horizontal) </span><b style="color: #cc0000;"><br /></b></div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_centerVertical="true"</b></div>
</div>
<div style="text-align: left;">
<span style="color: black;"> (Position the </span>EditText<span style="color: black;"> in Center Vertical) </span></div>
Arise Rayamangalamhttp://www.blogger.com/profile/17522192478676631711noreply@blogger.com1tag:blogger.com,1999:blog-9176720325012787290.post-80734918617583247262013-01-13T08:03:00.000-08:002013-02-07T19:22:16.033-08:006. XML format for TextView and TextView parameters<br />
<h3>
<b><span style="font-weight: normal;">1.</span></b><u>Format of a TextView</u></h3>
<br />
<div style="color: red;">
<b> <span style="color: blue;"><TextView</span><br style="color: blue;" /><span style="color: blue;"> android:id="@+id/textView1"</span><br style="color: blue;" /><span style="color: blue;"> /></span></b></div>
<div style="color: red;">
<br /></div>
(Note: here the id of the TextView is "textView1".)<br />
<br />
<h3>
<span style="font-weight: normal;">2.</span><u><b>Important TextView Parameters</b></u></h3>
<b></b><u><b></b></u><br />
<br />
<div style="color: #cc0000;">
<b> <span style="color: blue;">android:layout_width="wrap_content"</span></b><span style="color: black;"> </span></div>
<div style="color: #cc0000;">
<span style="color: black;"> (restrict the width of the layout to the content width, eg. width of text)</span></div>
<div style="color: #cc0000;">
<br /></div>
<div style="color: blue;">
<b> android:layout_width="match_parent" </b></div>
<div style="color: #cc0000;">
<b> </b><span style="background-color: white; color: black;">(extend the width to the parent width.eg.fill the screen width</span><span style="color: black;">)</span></div>
<div style="color: #cc0000;">
<br /></div>
<div style="color: blue;">
<b> android:layout_height="wrap_content" </b> </div>
<div style="color: #cc0000;">
<span style="color: black;"> (restrict the height of the layout to the content height. eg. height of text)</span></div>
<div style="color: #cc0000;">
<br /></div>
<div style="color: blue;">
<b> android:layout_height="match_parent"</b><b> </b></div>
<div style="color: #cc0000;">
<b> </b><span style="background-color: white; color: black;">(extend the height to the parent height</span><span style="color: black;">.eg. fill the screen height)</span></div>
<br />
<div style="color: blue; text-align: left;">
<b> android:text="@string/hello"</b></div>
<div style="text-align: center;">
(Display the text stored in the string named "hello". string is to be specified in the "strings.xml' file in the folder named "values" as follows)</div>
<div style="text-align: left;">
<span style="color: lime;"> </span><span style="color: blue;"><string name="hello">your text here</string></span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b><span style="color: red;"> <span style="color: blue;"> android:hint="@string/hint1"</span></span></b></div>
<div style="text-align: left;">
<div style="text-align: center;">
(Display a text when the field is empty. Will automatically disappear when a text is shown. The hint text is storedin a string called " hint1", string is to be specified in the "strings.xml' file in the<br />
folder named "values as follows)</div>
<div style="text-align: left;">
<span style="color: lime;"> </span><span style="color: blue;"><string name="hint1">your text here</string></span></div>
</div>
<div style="text-align: left;">
<b style="color: #cc0000;"> </b><br />
<b style="color: #cc0000;"> <span style="color: blue;"> android:textColor="@color/white"</span></b><span style="color: #cc0000;"> </span></div>
<div style="text-align: center;">
<span style="color: #cc0000;"><span style="color: black;"> (</span></span><span style="color: black;">Apply the color stored in the string"</span><span style="color: black;">white</span><span style="color: black;">". string is to be specified in the "strings.xml in the folder </span><span style="color: black;">named </span><span style="color: black;"> "values" as follows)</span></div>
<div style="text-align: left;">
<b style="color: #cc0000;"> </b><span style="color: #cc0000;"> <span style="color: blue;"> <color name="white">#FFFFFF</color></span></span></div>
<div style="text-align: left;">
<b style="color: #cc0000;"><br /></b></div>
<div style="text-align: left;">
<b style="color: #cc0000;"> <span style="color: blue;">android:textSize="15sp"</span></b></div>
<div style="text-align: left;">
<b style="color: #cc0000;"> </b><span style="color: #cc0000;"><span style="color: black;"> (Display t</span></span><span style="color: black;">he size of the text in 15 scaled pixels, device independent)</span></div>
<div style="text-align: left;">
<br />
<b style="color: #cc0000;"> <span style="color: blue;">android:textStyle="bold"</span></b></div>
<div style="text-align: left;">
(Display the text as bold)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:typeface="serif"</b></div>
</div>
<div style="text-align: left;">
(Display the text in "serif" font)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:height="15sp"</b></div>
</div>
<div style="text-align: left;">
(Fix the height of the textview to 15sp)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:gravity="1"</b></div>
<div style="color: blue;">
<b> android:gravity="2"</b></div>
</div>
<div style="text-align: center;">
(If the gravity of item1 is "1" and of item2 is "2" both will occupy the area in the ratio 1:2, default gravity=0)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:gravity="center"</b></div>
</div>
<div style="text-align: left;">
(Display the text in the center of textview)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:background="@drawable/picture"</b></div>
</div>
<div style="text-align: left;">
<div style="text-align: center;">
(Set the background to an image called "picture.PNG", only PNG type image is supported. The image is to be stored in folder res>drawable-mdpi)</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
</div>
<div style="color: blue;">
<b> android:layout_marginLeft="20dp"</b></div>
</div>
<div style="text-align: left;">
(A space of 20dp is kept on the left side)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_marginRight="20dp"</b></div>
</div>
<div style="text-align: left;">
(A space of 20dp is kept on the right side)</div>
<div style="text-align: left;">
</div>
<div style="color: blue; text-align: left;">
<b>android:layout_marginBottom="20dp"</b> </div>
<div style="text-align: left;">
(A space of 20dp is kept on the bottom)<br />
<div style="text-align: left;">
</div>
</div>
<div style="color: blue; text-align: left;">
<b> android:layout_marginBottom="20dp"</b> </div>
<div style="text-align: left;">
(A space of 20dp is kept on the top) </div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_alignParentTop="true"</b></div>
</div>
<div style="text-align: left;">
(Position the TextView at top of the parent. eg. top of screen)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_alignParentBottom="true"</b></div>
</div>
<div style="text-align: left;">
(Position the TextView at bottom of the parent. eg. bottom of screen)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_alignParentRight="true"</b></div>
</div>
<div style="text-align: left;">
(Position the TextView at right side of the parent. eg. right side of screen)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_alignParentLeft="true"</b></div>
</div>
<div style="text-align: left;">
(Position the TextView at left side of the parent. eg. left side of screen)<br />
<b style="color: #cc0000;"> </b><br />
<div style="color: blue;">
<b> android:layout_alignBottom="@+id/button1"</b></div>
</div>
<div style="text-align: left;">
(Align the bottom of the TextView to button1)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_toRightOf="@+id/button1"</b></div>
</div>
<div style="text-align: left;">
(Align the TextView to the right of button1)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_toLeftOf="@+id/button1"</b></div>
</div>
<div style="text-align: left;">
(Align the TextView to the left of button1)</div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_centerHorizontal="true"</b></div>
</div>
<div style="text-align: left;">
<b style="color: #cc0000;"> </b><span style="color: black;">(Position the TextView in Center Horizontal) </span><b style="color: #cc0000;"><br /></b></div>
<div style="text-align: left;">
<br />
<div style="color: blue;">
<b> android:layout_centerVertical="true"</b></div>
</div>
<div style="text-align: left;">
<span style="color: black;"> (Position the TextView in Center Vertical) </span></div>
<div style="text-align: left;">
<br />
<b style="color: #cc0000;"> <span style="color: black;"> see the Format of EditText and Imporatant EditText Parameters In</span> <a href="http://android-helper4u.blogspot.in/search/label/7.%20XML%20format%20for%20EditText%20and%20EditText%20parameters" target="_blank">NEXT CHAPTER</a></b></div>
Arise Rayamangalamhttp://www.blogger.com/profile/17522192478676631711noreply@blogger.com4tag:blogger.com,1999:blog-9176720325012787290.post-16729506439719383842013-01-10T05:55:00.001-08:002013-02-07T19:22:47.801-08:004. Basics of Files,Folders and how to Run the Project in AndroidNow your screen will be looking like the Image below.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-gvPZOeMOP3s/UO62Ev2szqI/AAAAAAAAATM/Qdod_j9-WKE/s1600/screen12.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://1.bp.blogspot.com/-gvPZOeMOP3s/UO62Ev2szqI/AAAAAAAAATM/Qdod_j9-WKE/s640/screen12.png" width="640" /></a></div>
<br />
<br />
In the Package Explorer there is a <span style="background-color: yellow;">Main Folder </span>named <span style="background-color: yellow;">"sample"</span>, ie. your project name. <span style="background-color: yellow;">Click</span> on the folder to expand it. Now you can see the following folders and some other folders which are not relevant to us.<br />
"src" folder is the source folder (that is why the name),<br />
"gen" folder is the Generated folder (Thats why the name)<br />
"res" folder is the resources folder (That is why the name).<br />
<br />
<br />
Now click on the following folders step by step to expand it. (I have given > means click on the folder)<br />
<b><span style="background-color: yellow;">src > com.example.sample > MainActivity.Java</span></b><br />
<br />
"src" contains the source files of your project. The <span style="background-color: yellow;">"MainActivity.Java"</span> is the <span style="background-color: yellow;">Main java file</span> of your project. You may double click to open it. You should know Java to program it. For this project we are not doing anything in it so<span style="background-color: yellow;"> close it</span>.<br />
<br />
"gen" folder contains an automatically generated Java files. Don't modify any files here because your application will not work.<br />
<br />
Now <span style="background-color: white;">click</span> on the following file<span style="background-color: white;"> to expand </span>it<span style="background-color: yellow;"><span style="background-color: white;"> <br />
</span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;">res >values > strings.xml & styles.xml</span> </span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;">The values of strings,colors used etc are given in the strings.xml file.</span></span><br />
<br />
Now <span style="background-color: white;">click</span> on the following file<span style="background-color: white;"> to expand </span>it<br />
<b><span style="background-color: yellow;">res> layout >activity_main.xml</span></b><br />
<br />
It contains the Main Layout files/XML files for your project. Now <span style="background-color: yellow;">double click</span> on the <b><span style="background-color: yellow;">activity_main.xml<span style="background-color: white;"> </span></span></b><span style="background-color: yellow;"><span style="background-color: white;">now you can see</span></span><span style="background-color: yellow;"><span style="background-color: white;"> activity_main.xml file as in the image</span></span><span style="background-color: yellow;"><span style="background-color: white;">. There are two tabs in the bottom, Graphical Layout and </span></span><span style="background-color: yellow;"><span style="background-color: white;">activity_main.xml. You can modify the file in both the modes. You may drag and drop the form widgets in the Graphical Layout to create Button,Textview etc. When you do so the corresponding XML code will be automatically generated in the </span></span><span style="background-color: yellow;"><span style="background-color: white;">activity_main.xml. If you drag and drop you can give the parameters in the left side box.It is the easiest method for this project,however knowing xml is essential, but if you want to do it through Graphical method go to the Heading "<b>Using Graphical Method</b>" below)</span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"> </span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"> For our project </span></span><span style="background-color: yellow;"><span style="background-color: white;">we are modifying the xml file. Click on the </span></span><span style="background-color: yellow;"><span style="background-color: white;">activity_main.xml<span style="background-color: yellow;"> tab</span>. Now you can see the xml codes. (see the image below)</span></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-ruAp4FUgXEY/UO675Vl4u6I/AAAAAAAAATc/Jpk4J5IQ4NA/s1600/screen6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://1.bp.blogspot.com/-ruAp4FUgXEY/UO675Vl4u6I/AAAAAAAAATc/Jpk4J5IQ4NA/s640/screen6.png" width="640" /></a></div>
<br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;">There is a<span style="background-color: yellow;"> <textview</span> given and below that there is a<span style="background-color: yellow;"> android:text="@string/hello_world"/><span style="background-color: white;"> In Android the text are displayed in "textviews" you have to create a text view in order to display a text. Since Android have already created a "textview" for us you can just modify to display your own text. "android:text=" is the syntax for displaying text in xml. It means you are specifying a text here to display. Now the "@string/hello_world" means the text is stored in a "string" called "hello_world" if you see the if you open </span></span></span></span><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;">res >values > strings.xml<span style="background-color: white;"> you can see the string as well as the text as follows </span></span></span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><string name="hello_world">Hello world!</string></span> Here "hellow_world" is the string used to store the text "Hello world!" (Dont confuse both you can even store the text in a string named "abc".) if you change the text you can display your own text.</span></span></span></span><br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"> Now we are going for an easiest method to display your own text. (Good practice is to use the string to store the text) Replace the </span></span></span></span><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;">@string/hello_world<span style="background-color: white;"> and just type your name (starting with I am Mr..)within the double quotes.</span></span></span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">(see the image below)</span></span></span></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-wm0qPC1mVuc/UO68kZWHX_I/AAAAAAAAATk/RgYbt5FhKvM/s1600/screen7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://1.bp.blogspot.com/-wm0qPC1mVuc/UO68kZWHX_I/AAAAAAAAATk/RgYbt5FhKvM/s640/screen7.png" width="640" /></a></div>
<br />
<br />
<u><b><span style="background-color: yellow;"><span style="background-color: white;">Using Graphical Method</span></span></b></u><br />
<span style="background-color: yellow;"><span style="background-color: white;">This is the easiest method for this project. First select the Graphical Layout Tab, and click on the form widget on the left side (see the image below), now drag and drop it to the blank page, you can see a blue rectangular outline, click on it and you can specify the text,text size,style etc on the properties window right side.</span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><br /></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-3FPRXZFhxfc/UO_es-8Q2tI/AAAAAAAAAVw/9yr6ccWOnMM/s1600/Graphical+Layout.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://1.bp.blogspot.com/-3FPRXZFhxfc/UO_es-8Q2tI/AAAAAAAAAVw/9yr6ccWOnMM/s640/Graphical+Layout.png" width="640" /></a></div>
<span style="background-color: yellow;"><span style="background-color: white;"></span></span>
<br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">Now you have successfully created a project to display your own name while running the application. Before running you have to make an Android Virtual Device Manager (known as AVD) to see the result same as in the Mobile phone. It is very easy. Just click the </span></span></span></span><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">Virtual Device Manager icon from the tool bar (see the image below)</span></span></span></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-oPRm1wcOCKk/UO69xwl0XnI/AAAAAAAAATw/viL8w8GlIe8/s1600/screen8.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://1.bp.blogspot.com/-oPRm1wcOCKk/UO69xwl0XnI/AAAAAAAAATw/viL8w8GlIe8/s640/screen8.png" width="640" /></a></div>
<br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">Now you will get a child window named <span style="background-color: yellow;">Android Vertual Device Manager</span>. click "<span style="background-color: yellow;">New</span>" to create a new one. Another child window named create new Android Virtual Device (AVD) is open, Now give the following in the respective fields, (see the image below)</span></span></span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">AVD Name:<span style="background-color: yellow;"> "vertualDevice"</span> (don't give space) </span></span></span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">Device: <span style="background-color: yellow;">4.7" WXGA (1280x720:xhdpi)</span> (you can select any virtual device to imitate the phone or tablet)</span></span></span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">Keyboard : "<span style="background-color: yellow;">Click to tick</span>" Hardware keyboard present. (otherwise you cannot enter text from computer keyboard)</span></span></span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">Skin: "<span style="background-color: yellow;">Click to tick</span>" display a skin with hardware control (so that it will give the option of menus and back button)</span></span></span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">Internal Storage: <span style="background-color: yellow;">200 MiB</span></span></span></span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">SD Card Size : <span style="background-color: yellow;">200 MiB </span></span></span></span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">Now click <span style="background-color: yellow;">Ok </span>to create the AVD. Now your AVD is created and you can run your project.</span></span></span></span></span></span><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-l6P974SE9cU/UO7Bt4bazfI/AAAAAAAAAUE/TQg7cD4psQk/s1600/screen9.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://3.bp.blogspot.com/-l6P974SE9cU/UO7Bt4bazfI/AAAAAAAAAUE/TQg7cD4psQk/s640/screen9.png" width="640" /></a></div>
<br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">To Run your project <span style="background-color: yellow;">click on the RUN</span> button (see the image below). No child window is opened select "<span style="background-color: yellow;">Android Application"<span style="background-color: yellow;"></span></span> and press "<span style="background-color: yellow;">OK</span>" </span></span></span></span></span></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-L7S_IZ8n9cs/UO7DM3KCPnI/AAAAAAAAAUU/9g1D_HPbGlA/s1600/screen10.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://1.bp.blogspot.com/-L7S_IZ8n9cs/UO7DM3KCPnI/AAAAAAAAAUU/9g1D_HPbGlA/s640/screen10.png" width="640" /></a></div>
<br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">Now your AVD is automatically launched ( see the image below)</span></span></span></span></span></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-fGQJNqM2_WI/UO7EEbzo84I/AAAAAAAAAUg/xT8NVpmajQM/s1600/screen11.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://1.bp.blogspot.com/-fGQJNqM2_WI/UO7EEbzo84I/AAAAAAAAAUg/xT8NVpmajQM/s640/screen11.png" width="640" /></a></div>
<br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">After some time your application will be launched </span></span></span></span></span></span><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">(It will take<span style="background-color: yellow;"> some 3-4 Minutes</span> to launch) </span></span></span></span></span></span><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">and your name will be shown in the screen. (As shown below)</span></span></span></span></span></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-hnynPdhZ-6U/UPJvJOJgpEI/AAAAAAAAAaA/pbsM45HCAdM/s1600/sample-screenshot.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="360" src="http://3.bp.blogspot.com/-hnynPdhZ-6U/UPJvJOJgpEI/AAAAAAAAAaA/pbsM45HCAdM/s640/sample-screenshot.png" width="640" /></a></div>
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"> </span></span></span></span></span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">That's it. You have created your first application. Do experiment with the Graphical Layout, drag and drop many textviews in the layout and try to display different texts and give different formatting to the text. You may read the android tutorials given under the Resources in the right side. Plenty of Android forums will give you answer to any of your questions. Just search in the search box (customized for Android Development forums and sites ) given above. Thank You,</span></span></span></span></span></span><br />
<br />
<span style="background-color: lime;">(TIP) </span>For better performance and avoid crashing, always launch AVD from AVD Manager and click the option "Scale display to real size"<br />
<br />
<br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"> <b> Best of Luck </b></span></span></span></span></span></span><br />
<br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;">We will discus how to export your Application as APK (Android Package File) </span></span></span></span></span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"> in the <a href="http://android-helper4u.blogspot.in/search/label/5.%20How%20to%20sign%20and%20export%20%20and%20publish%20APK%20application%20file%20in%20Andrioid" target="_blank">NEXT CHAPTER </a></span></span></span></span></span></span><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"><span style="background-color: yellow;"><span style="background-color: white;"><b><br /></b></span></span></span></span></span></span>Arise Rayamangalamhttp://www.blogger.com/profile/17522192478676631711noreply@blogger.com5tag:blogger.com,1999:blog-9176720325012787290.post-18012934720425539762013-01-10T03:59:00.003-08:002013-02-07T19:23:59.219-08:003. Creating a New Simple Android Project So you have got a basic knowledge about Eclipse. Now we can go ahead to create a sample project and understand the basic file types,folders,XML file and Java file. To <span style="background-color: yellow;">create a New Android Project</span> go to the toolbar and click <span style="background-color: yellow;">File>New>Android Application Project</span> (See the image below for details)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-qXxgGW9s7ig/UO6cpj7EoKI/AAAAAAAAAR8/ixpuZYvSn5g/s1600/screen1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://2.bp.blogspot.com/-qXxgGW9s7ig/UO6cpj7EoKI/AAAAAAAAAR8/ixpuZYvSn5g/s640/screen1.png" width="640" /></a></div>
<br />
<br />
Now you will get a child window asking you to enter the project details.(see the image below) Give the <span style="background-color: yellow;">Application Name</span> as <span style="background-color: yellow;">sample</span>. Now the project name and Package name will be automatically filled up. No need to change these details. Note that your project name should be unique so as to identify your application in Google Play (Where you can upload your Application). That is why it has chosen a reverse domain name. <span style="background-color: lime;">(TIP)</span> But if your package name start with<span style="background-color: yellow;"> com.example, com.google or com.android</span> they will not accept your file. For next project better you can give a starting name as "com.yourname" because <span style="background-color: yellow;">it is to be unique</span> in Google Play.<br />
Anyway we are not changing other details for this project<span style="background-color: yellow;">.Minimum Required SDK</span> is the Minimum API level corresponding to the Android version. For example by setting a minimum API level of 8 and Android version 2.2 (named 'froyo'), your project will be able to run in the Mobile phone with earlier Android version ie. 'froyo'. The current Android version is Android 4.1 (Jelly Bean). Set it to the lowest as possible to make maximum compatibility.But if you do so you will not be able to use the advanced features incorporated in the latest versions. For this project don't change these fields.Also Leave other fields as it is.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-KQ4sn3Uh6T8/UO6l3eHU96I/AAAAAAAAASM/IdSHP5hVP6k/s1600/screen2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://1.bp.blogspot.com/-KQ4sn3Uh6T8/UO6l3eHU96I/AAAAAAAAASM/IdSHP5hVP6k/s640/screen2.jpg" width="640" /></a></div>
<br />
<br />
On the next screen ie. <span style="background-color: yellow;">configure project</span> don't change anything <span style="background-color: yellow;">click Next</span>.<br />
<br />
On the next screen you will be able to select an<span style="background-color: yellow;"> icon for your application</span>(see the image below). This icon will be displayed in along with your application name in the phone if you install it in a phone. So chose a good icon, you can <span style="background-color: yellow;">choose any photo</span> by clicking <span style="background-color: yellow;">browse</span> and Eclipse will convert it in to an icon. You can <span style="background-color: yellow;">select the shape</span> of icon as <span style="background-color: yellow;">square and circle</span>. Click<span style="background-color: yellow;"> Next to continue</span>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-maGhfEi3WwA/UO6oIyX-SpI/AAAAAAAAASc/3OT7LPTvuUA/s1600/screen3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://3.bp.blogspot.com/-maGhfEi3WwA/UO6oIyX-SpI/AAAAAAAAASc/3OT7LPTvuUA/s640/screen3.png" width="640" /></a></div>
<br />
<br />
<span style="background-color: yellow;">Next screen</span> is create activity. For this project select a <span style="background-color: yellow;">"Blank Activity"</span> (see the image below)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-QAT9q5zW9Cg/UO6pSXuwxkI/AAAAAAAAASs/OxHKcfd8t_s/s1600/screen4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://4.bp.blogspot.com/-QAT9q5zW9Cg/UO6pSXuwxkI/AAAAAAAAASs/OxHKcfd8t_s/s640/screen4.png" width="640" /></a></div>
<br />
<br />
On the <span style="background-color: yellow;">next screen</span> you can create <span style="background-color: yellow;">a new blank activity</span> (see the image below). For this project <span style="background-color: yellow;">no need to change the default name</span>. But if you want can give a new name so that the file can be easily identified when different projects are simultaneously opened. If give a new name in the Activity Name, Layout name will be automatically changed. (Note that the Activity name is the name of the Java file and Layout name is the name of XML file, we will discus it later) Now click <span style="background-color: yellow;">FINISH</span> to create the project.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-sHFiH9nxbpQ/UO6rz2nCUCI/AAAAAAAAAS8/vorP6BAsRvI/s1600/screen5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://3.bp.blogspot.com/-sHFiH9nxbpQ/UO6rz2nCUCI/AAAAAAAAAS8/vorP6BAsRvI/s640/screen5.png" width="640" /></a></div>
<br />
<br />
Now your project is created with some files in the Package explorer and a Graphical Layout. Before starting you should know the different types of file and what is a Graphical Layout and XML Layout.<br />
<br />
Now you can move to the <b><a href="http://android-helper4u.blogspot.in/2013/01/creating-new-sample-application-in.html" target="_blank">NEXT CHAPTER</a></b>Arise Rayamangalamhttp://www.blogger.com/profile/17522192478676631711noreply@blogger.com8tag:blogger.com,1999:blog-9176720325012787290.post-30055955603636007762013-01-10T02:01:00.002-08:002013-02-07T19:24:23.149-08:002. How to work in Android SDK (Eclipse) So you have downloaded and extracted the Android SDK from <a href="http://developer.android.com/sdk/index.html" target="_blank">Google's Developer Site</a>. If you have not opned Eclipse, then go the folder where you have extracted the SDK and open the folder named <span style="background-color: yellow;">"adt-bundle-windows-x86"</span> then, go to the <span style="background-color: yellow;">"eclipse"</span> folder and click the<span style="background-color: yellow;"> "Eclipse.exe"</span> file. You may create a shortcut in the desktop by right clicking the file and send to desktop for easy use.<br />
<br />
When you open Eclipse, it will ask you to give a workplace<span style="background-color: yellow;"> location</span> to store your project data. Choose an easy location like My Documents so that you can easily find the folder later. You can tick to save all projects in the same location. Click <span style="background-color: yellow;">OK</span> and now you can see the following screen. On the extreme left there is a<span style="background-color: yellow;"> package explorer</span> where you can explore your project files if you have created any projects. (You can also download and view the sources of sample projects here, using SDK Manager. That I will explain later. Now there is a green<span style="background-color: yellow;"> run button</span> on the middle of the toolbar. When you have created a project you can click here to Run (so that you can see the result) your project. The <span style="background-color: yellow;">Java perspective</span> on the extreme right top corner is the default environment where you to do the coding. The Console on the bottom will show you all the activities you are doing like running the application. <span style="background-color: yellow;">Log cat </span>will show you all of your project logs.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-hUP4DkRLujg/UO6QvRmHyYI/AAAAAAAAARs/2BLCuYMwU_Q/s1600/screen0.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://2.bp.blogspot.com/-hUP4DkRLujg/UO6QvRmHyYI/AAAAAAAAARs/2BLCuYMwU_Q/s640/screen0.png" width="640" /></a></div>
<br />
<br />
Now you have learn the basics of Eclipse platform. Now you have to create a sample project. That I will explain in the <b><a href="http://android-helper4u.blogspot.in/2013/01/creating-sample-android-project.html" target="_blank">NEXT CHAPTER </a></b>Arise Rayamangalamhttp://www.blogger.com/profile/17522192478676631711noreply@blogger.com6tag:blogger.com,1999:blog-9176720325012787290.post-45092002763400116932012-12-10T10:15:00.000-08:002013-02-07T19:24:45.346-08:005. How to sign and export and publish APK application file in Andrioid<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
Now you have already made a project named "sample". If you want to run it in your Android phone, you can copy the APK file from your workplace>sample>bin folder and copy & install it in to your phone. (see the picture for details)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-L8F8mbof7-c/UPGr4-9ymQI/AAAAAAAAAWY/jNA9wle20Og/s1600/screen13.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="374" src="http://3.bp.blogspot.com/-L8F8mbof7-c/UPGr4-9ymQI/AAAAAAAAAWY/jNA9wle20Og/s640/screen13.png" width="640" /></a></div>
<br />
This APK file will work in any compatible android phone but it contains an internal debugging key which is not acceptable if you want to publish in Google Play. Google Play need your APK file to be signed by yourself before publishing. It is very easy to create a key and sign the APK.<br />
Just you have to<span style="background-color: yellow;"> left click</span> on the <span style="background-color: yellow;">project folder</span> "sample" and select<span style="background-color: yellow;"> "export"</span> (see image below)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-XFZHq7J2me8/UPG8PW_-uiI/AAAAAAAAAWo/5W0YUluVSAA/s1600/screen14.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="374" src="http://1.bp.blogspot.com/-XFZHq7J2me8/UPG8PW_-uiI/AAAAAAAAAWo/5W0YUluVSAA/s640/screen14.png" width="640" /></a></div>
<br />
Now select <span style="background-color: yellow;">Export Android Application</span> and click<span style="background-color: yellow;"> NEXT</span> (see image)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-jMVL9T6cVwU/UPG8sDKj1nI/AAAAAAAAAWw/ckT-wrV8L5o/s1600/screen15.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="374" src="http://1.bp.blogspot.com/-jMVL9T6cVwU/UPG8sDKj1nI/AAAAAAAAAWw/ckT-wrV8L5o/s640/screen15.png" width="640" /></a></div>
<br />
On the next screen you can see the project name "sample" just click <span style="background-color: yellow;">next</span> (see image)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-DSaLq8xqbAg/UPG9KC8s0iI/AAAAAAAAAW4/jD8RTrPQo3s/s1600/screen16.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="374" src="http://3.bp.blogspot.com/-DSaLq8xqbAg/UPG9KC8s0iI/AAAAAAAAAW4/jD8RTrPQo3s/s640/screen16.png" width="640" /></a></div>
<br />
Now click on <span style="background-color: yellow;">create a "new key store"</span> as you are making a key for the first time. (see image below)<br />
Next time onwards you can use the same key to sign all of your projects.<br />
Now you have to save the key to a file, so click<span style="background-color: yellow;"> browse</span> and <span style="background-color: yellow;">type a file name</span> and click<span style="background-color: yellow;"> save</span>.<br />
You have to <span style="background-color: yellow;">give a password</span> for the key, you have to remember it, as it will be asked when next time an APK is signed. Type the <span style="background-color: yellow;">password again to confirm</span>.<br />
Now you click <span style="background-color: yellow;">NEXT</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-V-PRlYRJKeA/UPG_CQSklcI/AAAAAAAAAXI/gtZQbP8pyO8/s1600/screen17.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="374" src="http://1.bp.blogspot.com/-V-PRlYRJKeA/UPG_CQSklcI/AAAAAAAAAXI/gtZQbP8pyO8/s640/screen17.png" width="640" /></a></div>
<br />
On the next screen you have to give the details for the key. Give the following details. (see image below)<br />
<span style="background-color: yellow;">Alias name:</span> you can give your name<br />
<span style="background-color: yellow;">Password:</span> just the same password you typed before<br />
<span style="background-color: yellow;">Validity:</span> Give a big number like 100 Years.<br />
<span style="background-color: yellow;">Organisational Unit</span>: Give any name like your family name<br />
<span style="background-color: yellow;">Organisation</span>: Give some name as above.<br />
<span style="background-color: yellow;">Country code:</span> Search for it in Google.<br />
When finished, Click <span style="background-color: yellow;">next</span> to continue<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-1LIRpBA-r3Q/UPHBVvcx-dI/AAAAAAAAAXY/7CUrVGZ-kjc/s1600/screen18.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="374" src="http://1.bp.blogspot.com/-1LIRpBA-r3Q/UPHBVvcx-dI/AAAAAAAAAXY/7CUrVGZ-kjc/s640/screen18.png" width="640" /></a></div>
<br />
<br />
<br />
On the next screen <span style="background-color: yellow;">click browse</span> and save your <span style="background-color: yellow;">signed APK file</span> in to a folder or desktop. Click finish to complete the setup.(see the image below). Congrats!! You can now publish it in Google Play.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-WPPcLBC76RU/UPHD12Iw3JI/AAAAAAAAAXo/trZyDRNowAk/s1600/screen19.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="374" src="http://1.bp.blogspot.com/-WPPcLBC76RU/UPHD12Iw3JI/AAAAAAAAAXo/trZyDRNowAk/s640/screen19.png" width="640" /></a></div>
<br />
<span style="background-color: lime;">(TIP)</span> Please remember that you have to give a one time developer fee of <span style="background-color: yellow;">$25/- for publishing in Google play</span>. If your package name start with<span style="background-color: yellow;"> com.example, com.google or com.android</span> they will not accept your file. better you can give a starting name as "com.yourname" because <span style="background-color: yellow;">it is to be unique</span> in Google Play.<br />
<span style="background-color: lime;">(TIP) </span>If you didn't change your package name while creating the project, Eclipse create your package name as com.example, to know how to change the package name go to this <a href="http://android-helper4u.blogspot.in/search/label/8.%20How%20to%20easily%20rename%20your%20package%20file%20in%20Android" target="_blank">CHAPTER</a><br />
<br />
Also before publishing you have to make to<span style="background-color: yellow;"> screen shot</span> of any of these types (see image for details)<br />
320x480,480x800,480x854,1280x720,1280x800 , 24bit, PNG or JPEG<br />
Also a <span style="background-color: yellow;">high resolution Application icon</span> of 512x512, 32bit image jpeg or png Max.1024KB<br />
As optional you can upload promotional graphic image of 180x120,24bit PNG or JPEG<br />
Optional feature graphic image of 1024x500,24 bit PNG or JPEG<br />
if you save normal images it will be 24bit. If you want 32bit image you should save as web image in Photoshop or add alpha (choose layers > Transparency>add alpha channel>save as PNG )to it in Open sourse <b>GNU Image Manipulation Program</b> <a href="http://sourceforge.net/projects/gimp-win/?source=dlp" target="_blank">(GIMP, click to download)</a><br />
You may also create optional youtube promotional videos. All these optional items will make your app more attractive.<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-VbAMuFAdwX8/UPHKJ6GvYBI/AAAAAAAAAX4/XhQWxbkOTpQ/s1600/google+play.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://2.bp.blogspot.com/-VbAMuFAdwX8/UPHKJ6GvYBI/AAAAAAAAAX4/XhQWxbkOTpQ/s640/google+play.png" width="640" /></a></div>
<br />
If you want to publish it free of charge then go to<a href="http://slideme.org/" target="_blank"> SlideMe</a> <span style="background-color: lime;">(TIP)</span> They don't accept simple applications, for that visit <a href="http://www.androidfreeware.net/" target="_blank">Android Freeware</a> <span style="background-color: lime;">(TIP) </span>You have to upload the APK file in to a file sharing site like <a href="https://www.rapidshare.com/" target="_blank">Rapid Share</a> First.<br />
<br />
Click the link below to visit <br />
<span style="font-size: large;"><a href="https://play.google.com/apps/publish/Home" target="_blank">Google Play Publish Page</a></span><br />
<br />Arise Rayamangalamhttp://www.blogger.com/profile/17522192478676631711noreply@blogger.com17