Android :Learn to make your own Android App

Android applications are in great demand in the market ,and that how it attarcts more freaky programmers to develop apps for Android. Today ,I am going to demonstrate how to display any text in the Android App .

If you are newbie to Java,then this is not the right place for you,just brush up Java before you start here.At first you need to install Android SDK as per your system.For installation help click here http://developer.android.com/sdk/installing/index.html

NOW FOLLOW THE FOLLOWING STEPS
STEP 1: Start Eclipse.Once it is started.Go to File

File->New->Android Application Project.

android1

A dialog box will appear ,name is whatever you wish like i have given it name as Android_1
If you are asked to select a build target,and if you have installed Android API,choose API level as shown in the picture below.
android 4
Once selected click Next.
NOTE: The name of the package should be unique as once you will upload this app to Google Android marketplace.You Android App will be recognized with unique package name.

STEP 2: Now we need to create an activity.Activity is basically the layout structure that we want to display in our App.
Select Blank Activity on clicking next after Step 1.
Give the name of the Activity as I have given the name of the activity as Android_test
and click Finish
a6-03-15 12:03:36

FInally go to Window->AVD Manager and start your target emulator( An emulator is a virtual Android device to run Android Apps ).

STEP 3: Go to ECLIPSE  and see the Project Explorer ,and you will see all the files  listed in your project like the following image.

a7

Now open AndroidManifest.xml and you will find the codes as

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android_1"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.android_1.Android_test"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".Second_activity" android:label="@string/app_name"/>

    </application>

</manifest>

Brief Explanation about AndroidManifest.xml:-

AndroidManifest.xml file contains app specific settings such as app version and minimum SDK version.The different permissions required,activities that can be run,services,broadcast receives and more.
Once open,it will open in default graphical view,change it into AndroidManifest.xml view at the bottom right of your view of the manifest .
At the top level under application you are specifying icons and label.The main function of intent filter stuff is that it specifies what should launch when an App runs.

And again go to project Explorer and search for “res” folder and res->values>string.xml and the string.xml will open like shown below .

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">android_1</string>
    <string name="hello_world">Hello world! THIS IS MY ANDROID TUTORIAL</string>
    <string name="menu_settings">Settings</string>
     <string name="test_one"> THIS IS MY FIRST ANDROID PROGRAM</string>
     <string name="click_me">Click Me</string>

</resources>

you will see that two strings are already created.If you look at the AndroidManifest.xml file ,you will find
@String/app_name.It is referring to the app_name string seen here.This string.xml is basically a resource file.These are heavily used in Android to make it easier to localize your application.
Again move on to res/layout/activity_android_test.xml.You will see a file a like this

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@string/click_me"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Android_test" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/hello_world"
        android:id="@+id/lblTextViewOne" />


    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editText1"
        android:layout_below="@+id/editText1"
        android:layout_marginLeft="64dp"
        android:layout_marginTop="39dp"
        android:onClick="@string/test_one"
        android:text="CLICK ME" />
</RelativeLayout>

Relative Layout is the way of containing and organizing element inside of it.The Relative Layout is used to display a block of text.

STEP 3: Now go to src->com.Example.Android_1
and open the Android_test.java file once there.And write the code as given given:

package com.example.android_1;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Android_test extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_android_test);

		final TextView TextViewOne = (TextView) findViewById(R.id.TextViewOne);
		TextViewOne.setText(R.string.test_one);

		}

}

Explantation of Android_test.java
Android_test class is extending the Activity class (which is part of Android SDK).We are only overriding one method from the Activity subclass,the “onCreate” method .This method is called when the activity is created and also when the screen is rotated.We call super.onCreate method so that the Activity subclass can handle its plumbing and then we call setContentView .This method is passed R.Layout.main .R is a way to refer to res folder and is how we pro-grammatically access the items in that folder.

STEP 4:
All we need to do is to create a new string and then use your TextView to use that String in the onCreate method.
let’s add an string to string.xml

<stringname="test_one">This is my first App</string>

Screenshot from 2013-03-15 12:25:29
then go back to activity_android_test.xml/main.xml

and add an id to it like

android:id="@+id/newtext"

again go to Android_test.java and write the following code

 TextView newtext=(TextView)findViewById(R.id.newtext)

if there is an error coming just import “TextView” or (android.widget)
again set the property of the Textview as

TextViewOne.setText(R.string.test_one);

Now your app is ready is ready to run.Just clean and build and RUN AS ANDROID APPLICATION
You will see an updated text.

Advertisements

Joomla Tutorials!! Convert HTML Template to Joomla Template

STEP 1. Prepare your template.The template must be HTML & CSS compliant.There are so many HTML Template on the Internet.Download it rename the index.HTML to index.php .Joomla will search for index.php in the template directory.

neerajtemplate

STEP 2. Replace the HTML code before the body tag of your file(index.php) with this code:

&lt;!--?php //no direct access  defined('_JEXEC')or die('Restricted access'); ?--&gt;
&lt;! Doctype html Public&quot;_ 1.dtd&quot;&gt;
&lt;head&gt;&lt;jdoc:include type=&quot;head&quot;/&gt;
&lt;link rel=&quot;stylesheet href=&quot; /&gt;baseurl?&gt;/template/system/css/system.css&quot; type=&quot;text/css&quot;/&gt;&lt;/head&gt;

all we need to do is to make minor changes in the code shown below

&lt;link rel=&quot;stylesheet href=&quot; /&gt;baseurl?&gt;/template/your_template_name/your_css_directory/your_css_filename.css&quot; type=&quot;text/css&quot;/&gt;

STEP 3. Now we have place various module positions inside your(index.php) file

&lt;jdoc:include type=&quot;modules&quot; name=&quot;your_module_position_name&quot;/&gt;

to appropriate position.The name attribute is the module position name snippet code is given below:-
Suppose there is a module known as logo .just make changes like this

&lt;div id=&quot;logo&quot;&gt;&lt;/div&gt;
&lt;jdoc:include type=&quot;modules&quot; name=&quot;top&quot;/&gt;&lt;/div&gt;

After that, you need to place a component. The code is shown below.

&lt;jdoc:include type=&quot;component&quot; /&gt;


STEP
4.Now we will create a manifest file.We need to create a manifest file to list all files we used.
If we don’t create it, it will cause error while installing our template. Here is the sample of a manifest file:

&lt;/pre&gt;
&lt;pre lang=&quot;enc__xml&quot;&gt;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;!DOCTYPE install PUBLIC &quot;-//Joomla! 1.5//DTD template 1.0//EN&quot; &quot;http://dev.joomla.org/xml/1.5/template-install.dtd&quot;&gt;
&lt;install version=&quot;1.5&quot; type=&quot;template&quot;&gt;
&lt;name&gt;your_template_name&lt;/name&gt;
&lt;creationDate&gt;25/01/2009&lt;/creationDate&gt;
&lt;author&gt;NEERAJ GOSWAMI&lt;/author&gt;
&lt;authorEmail&gt;neerajgoswami9@yahoo.in&lt;/authorEmail&gt;
&lt;authorUrl&gt;https://neerajpro.wordpress.com&lt;/authorUrl&gt;
&lt;copyright&gt;&lt;/copyright&gt;
&lt;license&gt;GNU/GPL&lt;/license&gt;
&lt;version&gt;1.0.0&lt;/version&gt;
&lt;description&gt;template description goes here&lt;/description&gt;
&lt;files&gt;
&lt;filename&gt;index.php&lt;/filename&gt;
&lt;filename&gt;templateDetails.xml&lt;/filename&gt;
&lt;filename&gt;template_thumbnail.png&lt;/filename&gt;
&lt;filename&gt;images/arrow.png&lt;/filename&gt;
&lt;filename&gt;images/logo.png&lt;/filename&gt;
&lt;filename&gt;css/template.css&lt;/filename&gt;
&lt;/files&gt;
&lt;positions&gt;
&lt;position&gt;breadcrumb&lt;/position&gt;
&lt;position&gt;left&lt;/position&gt;
&lt;position&gt;right&lt;/position&gt;
&lt;position&gt;top&lt;/position&gt;
&lt;position&gt;user1&lt;/position&gt;
&lt;position&gt;user2&lt;/position&gt;
&lt;position&gt;user3&lt;/position&gt;
&lt;position&gt;user4&lt;/position&gt;
&lt;position&gt;footer&lt;/position&gt;
&lt;position&gt;debug&lt;/position&gt;
&lt;position&gt;syndicate&lt;/position&gt;
&lt;/positions&gt;
&lt;/install&gt;

STEP 5: Nothing to do now.just zip it and install it.