Android ListView with multiple String arrays using Simple Adapter

Here is a Simple and very Easy tutorial if you want to show more than two lines in a single list item.

Steps:

  1. Create 2 layouts in res/layout folder. “main.xml” and   “list_item.xml”
  2. Create a listview in main.xml                (code given below)
  3. Create two textview in list_item.xml      (code given below)
  4. Create MainActivity and set main.xml as its layout. (code given below)
  5. Run the application.

source belowSource code:

Continue reading

Android Expandable List Simple example

Android Expandable List Simple example

This is a very important view of Android and it is really complicated but here is a very simple example for the ExpandableListView.

  • Create new Android Project with package name  “com.sagar.expandablelistview.example”.
  • Create Main Activity “ExpandableListExample.java”.
  • You don’t need any layout.xml for this example.
  • Copy the code in your ExpandableListExample activity.

source belowSource code:

Continue reading

Google Cloud Messaging For Android (GCM) Simple Tutorial

Important: C2DM has been officially deprecated as of June 26, 2012.

It has been replaced by Google Cloud Messaging For Android (GCM)

This Tutorial will guide you how to create a sample simple application using the GCM functionality,

This demo will help you registering and unRegistering android device from GCM server

Getting your Sender ID

  • STEP 1.  Register Here .
  • STEP 2.  Click Create project. Your browser URL will change to something like:
    " https://code.google.com/apis/console/#project:4815162342 "

    Take note of the value after #project: (4815162342 in this example). This is your project ID, and it will be used later on as the GCM sender ID. This Id will be used by the Android Device while Registering for Push Notification.

  • STEP 3. Choose Service tab from the left side menu on the web page. and turn on ” Google Cloud Messaging for Android “
  • STEP 4. Go to API Access tab from the left menu of web page.

press Create new Server key and note down the generated key

 

CREATING APP FOR GCM

Continue reading