Posts

Showing posts from March, 2012

Android Custom Alert Dialog

Image
                                     Android Custom Alert Dialog  1) AlertDialog is a small window that appears or pop up in front of your application.  2) It gets the screen focus and able to accept user interaction.  3) Dialogs are normally used for notifications that should interrupt the user and to perform short tasks. Step 1: Create a new project as CustomAlertDialog. Copy  the below coding and paste it into your main.xml file.   <?xml version="1.0" encoding="utf-8"?>   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="vertical" >   <Button         android:id="@+id/btn_alert"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:text="Alert Dialog" /> </LinearLay

Android Custom Toast Tutorial

Image
                                      Android Custom Toast 1) Toast is used to show simple message to the user. 2) Toast doesn't take focus,and not having interaction. 3) Based on the text size, the toast occupy the space in a screen. 4) By default it displays in bottom of the device. Step 1: Copy the below xml file and paste it in main.xml file <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="vertical" >     <Button         android:id="@+id/btn_short_toast"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:text="Short Toast" />     <Button         android:id="@+id/btn_long_toast"         android:layout_wid

Android Button State

Image
                                                        Button State In Android Here I post how to change the buttons background based on it's state. At the end of this tutorial i post the full source code. In that you can get button background images. This is the simple sample code, follow my instructions. Step 1:  Create new folder as "drawable" in res folder.In that folder create new " select.xml "  file and paste the below coding. <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android">     <item android:drawable="@drawable/ pressed_select " android:state_pressed="true" />     <item android:drawable="@drawable/ focused_select " android:state_focused="true" />     <item android:drawable="@drawable/ normal_select " /> </selector> Step 2: Copy the below coding and paste

Android Emulator Shortcuts

                         Android Simple Emulator Shortcuts     Here i post some of the useful android emulator shortcuts.  Use this shortcuts,it makes you perfect android developer.   Main Device Keys Home                 Home Button F2 Left Softkey / Menu / Settings button (or page up ) Shift + f2 Right Softkey / Star button (or page down ) Esc Back Button F3 Call/ dial Button F4 Hang up / end call button F5 Search Button Other Device Keys Ctrl + F5               Volume up (or + on numeric keyboard with Num Lock off) Ctrl + F6 Volume down (or + on numeric keyboard with Num Lock off) f7 Power Button Ctrl + F3 Camera Button Ctrl + F11 Switch layout orientation portrait/landscape backwards Ctrl + F12 Switch layout orientation portrait/landscape forwards F8 Toggle cell network F9 Toggle code profiling Alt + Enter Toggle fullscreen mode F6 Toggle trackball mode

Android Shortcuts

                      Android keyboard Shortcuts Scrolling • Spacebar: Page down in any Web page/document view • Shift + Spacebar: Page up in any Web page/document view   Typing • Alt + Spacebar: Insert a special character • Shift + Del: Delete the character to the right of the cursor • Alt + Del: Delete an entire line • Shift + Shift (press it twice): Activate caps-lock; press shift once more to exit • Alt + Trackball-Left: Move cursor to beginning of line • Alt + Trackball-Right: Move cursor to end of line • Alt + Trackball-Up: Move cursor to top of page • Alt + Trackball-Down: Move cursor to bottom of page • Shift + Trackball-Left/Right: Highlight text for cutting or copying • Menu + X: Cut text (will cut all text on-screen unless specific characters are highlighted) • Menu + C: Copy text to clipboard (will copy all text on-screen unless specific characters are highlighted) • Menu + V: Paste text from clipboard • Menu + A: Select all text i

Important Android Codes

                                                       Android secret codes DISCLAIMER: This information is intended for experienced users. It is not intended for basic users, hackers, or mobile thieves. Please do not try any of following methods if you are not familiar with mobile phones. We'll not be responsible for the use or misuse of this information, including loss of data or hardware damage. So use it at your own risk. *#*#4636#*#* This code can be used to get some interesting information about your phone and battery. It shows following 4 menus on screen: Phone information Battery information Battery history Usage statistics *#*#7780#*#* This code can be used for a factory data reset . It'll remove following things: Google account settings stored in your phone System and application data and settings Downloaded applications It'll NOT remove: Current system software and bundled applications SD card files e.g. photos,

Share Data Across Application in Android

Image
                       Share Data Across Application in android using Shared Preference * Android allow us to share data across applications. * Context.MODE_WORLD_READABLE is important thing in shared preference for global data access. * Run both project in the same emulator, Follow the below steps, Step 1: Create the android application name as " SharedPref1 " Package name as " com.sharepref1 " Copy the below code and paste it in main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="vertical" >     <EditText         android:id="@+id/edit_share_value"         android:layout_width="fill_parent"         android:layout_height="wrap_content" >         <requestFocus /&g

Screen Orientation in Android

Image
                                        Support Screen Orientation in Android Android project defaultly having main.xml file in layout folder. It supports both portrait and landscape. But some times our layout is not aligned well when skip to landscape mode. So we cannot able to get an expected view.Ex: textview ,button are misplaced. We can overcome this problem by using "layout-land" folder in our application. Step 1: Copy the below code and paste it in main.xml file which is in layout folder. <?xml version="1.0" encoding="utf-8"?>  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"        android:layout_width="fill_parent"        android:layout_height="fill_parent"        android:orientation="vertical" android:gravity="center">     <TextView         android:id="@+id/textView1"         android:layout_width="wrap_content"  

Android Project Structure 2012

Image
               src/      Contains package folder which having all our java files. gen/      This contains the Java files generated by ADT, such as your R.java file and interfaces created from AIDL files. Android jar/      Based on the version  you choose, it takes android jar file.      This jar file contains all its default android package with it. assets/      This is empty. You can use it to store raw asset files.      If you want to use some new font style you can put .ttf file here.  bin/      The bin folder contains our project’s apk file.      When running our project, the apk file uploaded in emulator for execution then show the output. res/      A folder for your application resources, the list below  * Animator/      It starts from 3.0 , used to animate properties of any object   it is more flexible and offers  more features     * anim/         Used to  perform a series of simple transformations like position, size, rota

Android Naming Conventions

Image
                            The android naming convention is same as java naming convertion. This Naming conventions are very important thing to follow while develop best android applications. Four things we need to concentrate while naming in android 1) Wheather it is a noun or verb. 2) Proper use of Characters . 3) No empty spaces are allowed. 4) Avoid using dollar($) symbol. Package      * Package name should be noun                    * Package name should be lowercase letters                    * Package name must be seperated with periods(.dot) Example:    c om. a ndroid. s hopping                  c om. b ank. a ccount Class          * Class name should be noun                  * Class name should Initcap.         Example:    A ccount H older, A ccount T ype Interface     * interface name should be noun.                    * interface name should Initcap. Example:     D ata H elper, A ccount N ame Method     * method name should be verb.