Wednesday, 20 March 2013

SIMPLE LISTVIEW WITH ARRAY ADAPTER

                                               1.CREATE NEW LISTVIEW PROGAMME
 ---------->Create New Project
--------------->Drag and Drop ListView From Palette
                                               2.CREATE ARRAY ADAPTER
 Values
--------------->String.xml
--------------------->ADD
------------------------->String array elements
----------------------------->Type Name of String Array
---------------------------------->Click String Array(name will shows)
---------------------------------------->Click Add
------------------------------------------->Item
----------------------------------------------->Ok
-------------------------------------------------->Type Item Value
(click the image)



                                                            3.SOURCE CODE

Src
------------->MainActivity.java
------------------>Create ListView variable
---------------------->Create Array Adaper
-------------------------->set Adapter to listview`s variable
-------------------------------->Create ListViewOnItemClickListner
----------------------------------->Check Item Clicked or not(arg2 is ID value like 0,1,2 of array adapter )
---------------------------------------->Display Toast Message


Coding:

public class MainActivity extends Activity {

    private ListView li;
    private ArrayAdapter<CharSequence> ar;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        li=(ListView)findViewById(R.id.listView1);
       
ar=ArrayAdapter.createFromResource(getApplicationContext(), R.array.adapter,
        android.R.layout.simple_list_item_1);
  
    li.setAdapter(ar);
    li.setOnItemClickListener(new OnItemClickListener()
    {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            if(arg2==0)
            {
Toast.makeText(getApplicationContext(), "ANDROID", Toast.LENGTH_LONG).show();   
            }           
        }
        }
        );
    }

Output shows like this.





 Thank you................................!



HOW TO CHANGE ONE SCREEN TO ANOTHER SCREEN

                                                    1.CREATE NEW PROJECT

Drag and Drop Button
------------------>Right Click Button
---------------------->EditText
---------------------------->Will be Open DialogBox
--------------------------------->NewString
------------------------------------>Type Button Name on STRING option(FirstScreen)
---------------------------------------->Type Resource Id on NEW STRING R.ID (fs1)
------------------------------------------->Click ok
now Your Button Name Will be change like FirstScreen


Now right click button ,choose properties then onClick name:call2 (refer simple project link)




                                                         2.Create Second Screen

Right click Layout folder from your project
-------------------------->New
------------------------------>Android xml file
--------------------------------->Type Name on file option(second)
Do first operation darg and drop button and edittext(SecondScreen)




                                                  3.Create Another One Activity Java file

Src
------------------>Copy MainActivity.java
------------------------>Paste Sre folder
----------------------------->Change Name :sec
---------------------------------->Change setContentView like this

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
public class sec extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.second);
    }


                                                             4.Intent Concept

Intent useful for jump One Activity to Another Activity
Src
-------------->Click MainActivity.java ,we have alredy create
                                 Method name using ONCLICK METHOD
                                       Name That is call2.
 --------------->Create function and use the INTENT SYNTEX

public class MainActivity extends Activity {
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void call2(View v)
    {
        Intent jump=new Intent(this,sec.class);
        startActivity(jump);
     }

                                                        5.ADD second Activity in AndroidManifest file

Click AndroidManifest.xml in your Project

------------------------>Application (bottom tap )
---------------------------->C option
---------------------------------->Activity
---------------------------------------->Add
----------------------------------------------->sec Activity
---------------------------------------------------->Ok

(Click this image for big view )

                                

Now Run Your Project..............!


CREATE SIMPLE ANDROID APPLICATION

                                                          Open your eclipse

1.File
---->NewProject
------------>Choose Android Application Project
------------------------>Type Your Project Name
----------------------------------->Click Next
------------------------------------------>Click Next
------------------------------------------------>Finish

Now project show like this........ 

                                                                                                                                                                                   



                                                   How to Drag And Drop Button into Display

2.Layout
--------------->Palette
------------------>Button 
---------------------->Drop on Display
Outline Shows Button link

---------------->Button
-------------------->Right Click Propertise
-------------------------->Onclick type Function Name

 See the Following Image




                                                  3.Click mail.xml options .It will Show like this




                                                                  4.Now go to Src file
--------------------------->Java file
--------------------------------->Create a Function as Button Onclick funcction name
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {
    Button but;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        but=(Button)findViewById(R.id.button1);
       
    }

    public void callme(View v)
    {
        but.setText("helloButton");
    }
}


https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6Nbvx-BabzQKvvGF5o9GLnSpjpdE66nUFbrtOPbVU_ArPO0k6CJHpIkl-GEAYpsTcOMh5hSyButHNgYZKN6I2Ycjtm1-bjvI-uuwpK9QaUo4pvpzEEDKofkyIuiFg2UKBNlhb031CnXY/s320/16.JPG


                                                5.Now you are ready to run you project

----------------->Right click the Project
------------------------>Configure
------------------------------>Android
----------------------------------->Target
----------------------------------------->Click Avd
----------------------------------------------->Apply
---------------------------------------------------->Run




                                                 6.Wait Few Seconds Auto open Emulator

----------------------------->Unlock
-------------------------------->Running Your Apps



                                                                       7.Click Button




That it ......





HOW TO PLUGIN AND USE

                                                       1.android sdk Unzip file open:

it will look like:




Click sdk manager It will shows





Install version SDK platform is important to emulator


                                        2.CONFIGURE AVD MANAGER







3.Emulator configure:






                                         3.PLUG IN ADT WITH ECLIPSE:
Open Eclipse :
click help options in menubar ---->Install software


Name:Type ADT or something
Location:Choose downloaded ADT ZIP file














Now restart Eclipse

Eclipse look like this:




                                           4.CHOOSE SDK LOCATION












Now you are ready to develop the android application.

DEVELOPMENT SOFTWARE DOWNLOAD

                                                                          All are freeware software

1.Java JDK download click the image                                                                                                           


Click


 2.Eclipse IDE                                                  


click



3.Android SDK

click
If you have slow internet speed  use Offline sdk download using InternetDownManager(IDM)
click following link.

                                                                          click me



4.Icon Creator(which is need key .if you need key ,you just ask me)


click


If you develop android game  download following software also



5. Inkscape - svg img creator


click
                                                                        

6.Gimp - graphics editor


click
                                                                              
                                                                                 

INTRODUCTION ABOUT ANDROID


Android is a Linux-based operating system designed primarily for touchscreen mobile devices such as smartphones and tablet computers.

Programmed : C, C++, Java

Source model: Open source

Official website www.android.com

Android, Inc. was founded in Palo Alto, California in October 2003 by Andy Rubin

Google acquired Android Inc. on August 17, 2005, making it a wholly owned subsidiary of Google

Versions:

Version Code name Release date API level Distribution (March 4, 2013)
4.2.x Jelly Bean November 13, 2012 17 1.6%
4.1.x Jelly Bean July 9, 2012 16 14.9%
4.0.x Ice Cream Sandwich December 16, 2011 15 28.6%
3.2 Honeycomb July 15, 2011 13 0.9%
3.1 Honeycomb May 10, 2011 12 0.3%
2.3.3–2.3.7 Gingerbread February 9, 2011 10 44%
2.3–2.3.2 Gingerbread December 6, 2010 9 0.2%
2.2 Froyo May 20, 2010 8 7.6%
2.0–2.1 Eclair October 26, 2009 7 1.9%
1.6 Donut September 15, 2009 4 0.2%