Friday, 29 June 2012

Google maps in Android a simple overview

Google maps in Android a simple overview



Here we can see how a simple google map is obtained.in this map view we are using a zoom control.and use the methode setanimateto() to locate the userdefined locations.here is sample code for this,









                                                                                                             



JithudemoActivity.java



package a.b;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MapView.LayoutParams;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

public class JithudemoActivity extends MapActivity
{  
    MapView mapView;
    MapController mc;
    GeoPoint p;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mapView = (MapView) findViewById(R.id.mapView);
        LinearLayout zoomLayout = (LinearLayout)findViewById(R.id.zoom);
        View zoomView = mapView.getZoomControls();

        zoomLayout.addView(zoomView,
            new LinearLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));
        mapView.displayZoomControls(true);

        mc = mapView.getController();
        String coordinates[] = {"8.487495", "76.948623"};
        double lat = Double.parseDouble(coordinates[0]);
        double lng = Double.parseDouble(coordinates[1]);

        p = new GeoPoint(
            (int) (lat * 1E6),
            (int) (lng * 1E6));

        mc.animateTo(p);
        mc.setZoom(17);
        mapView.invalidate();
    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
}


main.xml





<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <com.google.android.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:enabled="true"
        android:clickable="true"
        android:apiKey="0vNjDM-9Hpz8UM7pUWYJLvFptBpUpOqvQnV0S_g"
        />
        <LinearLayout android:id="@+id/zoom"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        />

</RelativeLayout>


















change the view to  satellite view



 by using the following methode


  mapView.setSatellite(true);







JithudemoActivity.java



package a.b;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MapView.LayoutParams;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

public class JithudemoActivity extends MapActivity
{  
    MapView mapView;
    MapController mc;
    GeoPoint p;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mapView = (MapView) findViewById(R.id.mapView);
        LinearLayout zoomLayout = (LinearLayout)findViewById(R.id.zoom);
        View zoomView = mapView.getZoomControls();

        zoomLayout.addView(zoomView,
            new LinearLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));
        mapView.displayZoomControls(true);

        mc = mapView.getController();
        String coordinates[] = {"8.487495", "76.948623"};
        double lat = Double.parseDouble(coordinates[0]);
        double lng = Double.parseDouble(coordinates[1]);

        p = new GeoPoint(
            (int) (lat * 1E6),
            (int) (lng * 1E6));

        mc.animateTo(p);
        mc.setZoom(17);
        mapView.invalidate();
     
     
        mapView.setSatellite(true);
    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
}



Thursday, 28 June 2012

Rate bar in android & Rate it,,,, with Source code

   Rate bar in android & Rate it,,,, with Source code

 

Here is an exaple for a rate bar ,which is used to rate cetain events or programs,here user can rate
the event ,,example program is given below,,








steps 1:


Eclipse- new android project-givename for project-select the target-give package name-then finish







source code


jithuActivity.java


package a.b;
 
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RatingBar;
import android.widget.RatingBar.OnRatingBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;
 
public class jithuActivity extends Activity {
 
  private RatingBar ratingBar;
  private TextView txtRatingValue;
  private Button btnSubmit;
 
  @Override
  public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
 
addListenerOnRatingBar();
addListenerOnButton();
 
  }
 
  public void addListenerOnRatingBar() {
 
ratingBar = (RatingBar) findViewById(R.id.ratingBar1);
txtRatingValue = (TextView) findViewById(R.id.txtRatingValue);
 
//if rating value is changed,
//display the current rating value in the result (textview) automatically
ratingBar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
public void onRatingChanged(RatingBar ratingBar, float rating,
boolean fromUser) {
 
txtRatingValue.setText(String.valueOf(rating));
 
}
});
  }
 
  public void addListenerOnButton() {
 
ratingBar = (RatingBar) findViewById(R.id.ratingBar1);
btnSubmit = (Button) findViewById(R.id.button1);
 
//if click on me, then display the current rating value.
btnSubmit.setOnClickListener(new OnClickListener() {
 
@Override
public void onClick(View v) {
 
Toast.makeText(jithuActivity.this,
String.valueOf(ratingBar.getRating()),
Toast.LENGTH_SHORT).show();
 
}
 
});
 
  }
}


main.xml



<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
        <TextView 
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceLarge" 
        android:layout_width="wrap_content" 
        android:text="your rating is : " 
        android:id="@+id/lblResult" 
        android:layout_x="23dp" 
        android:layout_y="281dp">
        </TextView>
        <RatingBar 
        android:stepSize="1.0" 
        android:id="@+id/ratingBar1" 
        android:numStars="3" 
        android:layout_height="wrap_content" 
        android:rating="1" 
        android:layout_width="wrap_content" 
        android:layout_x="29dp" 
        android:layout_y="173dp">
        </RatingBar>
        <Button 
        android:layout_height="wrap_content"
         android:layout_width="wrap_content" 
         android:text="submit" 
         android:id="@+id/button1" 
         android:layout_x="228dp" 
         android:layout_y="174dp">
         </Button>
        <TextView 
        android:layout_height="34dp" 
        android:layout_width="fill_parent" 
        android:text="rate the film" 
        android:layout_x="2dp" 
        android:layout_y="109dp">
        </TextView>
        <TextView 
        android:layout_height="44dp" 
        android:textAppearance="?android:attr/textAppearanceSmall" 
        android:layout_width="54dp" 
        android:text="" android:id="@+id/txtRatingValue" 
        android:layout_x="178dp"
         android:layout_y="284dp">
         </TextView>
 
   
</AbsoluteLayout>







output 










Friday, 22 June 2012

Array adapter list view in android

Array adapter list view in android


ArrayAdapterDemo.java




package a.b;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import  android.widget.ListView;
import android.widget.TextView;
public class  ArrayAdapterDemo extends ListActivity{
TextView t1;
String[] items= { "jithu", "is", "*", "really",
"good", "really3","really4",
"welcome", "jithu", "hai"};
@Override
public  void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,items));
t1=(TextView)findViewById(R.id.t1);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id)
{
super.onListItemClick(l, v, position, id);
String text = " position:"+ position + " "+ items[position];
t1.setText(text);
}
}

main.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffff0000"
    >
<TextView
android:id="@+id/t1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    />
    <ListView
android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:drawSelectorOnTop="false">
    </ListView>
    <TextView
    android:id="@+id/empty"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:text="empty list"/>
   
</LinearLayout>


output







simple android program using button and onclickListener

simple android program using button and onclickListener


RelativelayoutActivity.java


package a.b;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class RelativelayoutActivity extends Activity implements OnClickListener {
Button b1;
EditText e;
TextView t1;
String s1;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        e=(EditText)findViewById(R.id.ediUserName);
        b1=(Button)findViewById(R.id.btnGo);
        t1=(TextView)findViewById(R.id.lblUserName);
        b1.setOnClickListener(this);
        
    }
public void onClick(View v) {
// TODO Auto-generated method stub
s1=e.getText().toString();
if(v==b1)
{
t1.setText(s1);
}
}
}



main.xml


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/myRelativeLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff000000"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/lblUserName"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:background="#ff000066"
android:text="User Name"
android:textStyle="bold"
android:textColor="#ff00ff00"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true">
</TextView>
<EditText
android:id="@+id/ediUserName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/lblUserName"
android:layout_alignParentLeft="true"
android:layout_alignLeft="@+id/myRelativeLayout"
 android:padding="20dip">
 </EditText>
 <Button 
 android:id="@+id/btnGo"
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content"
  android:layout_below="@+id/ediUserName" 
  android:layout_alignRight="@+id/ediUserName" 
  android:text="Go" 
  android:textStyle="bold">
  </Button>
  <Button
   android:id="@+id/btnCancel" 
   android:layout_width="wrap_content" 
   android:layout_height="wrap_content"
 android:layout_toLeftOf="@+id/btnGo" 
 android:layout_below="@+id/ediUserName" 
 android:text="Cancel" 
 android:textStyle="bold">
 </Button>
 </RelativeLayout>

Thursday, 21 June 2012

Relative layout example in android

Relative layout example in android



main.xml



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/myRelativeLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff000000"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/lblUserName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffff0066"
android:text="User Name"
android:textStyle="bold"
android:textColor="#ff00ff00"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true">
</TextView>
<EditText
android:id="@+id/ediUserName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/lblUserName"
android:layout_alignParentLeft="true"
android:layout_alignLeft="@+id/myRelativeLayout"
 android:padding="20dip">
 </EditText>
 <Button 
 android:id="@+id/btnGo"
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content"
  android:layout_below="@+id/ediUserName" 
  android:layout_alignRight="@+id/ediUserName" 
  android:text="Go" 
  android:textStyle="bold">
  </Button>
  <Button
   android:id="@+id/btnCancel" 
   android:layout_width="wrap_content" 
   android:layout_height="wrap_content"
 android:layout_toLeftOf="@+id/btnGo" 
 android:layout_below="@+id/ediUserName" 
 android:text="Cancel" 
 android:textStyle="bold">
 </Button>
 </RelativeLayout>



output



example output






Friday, 8 June 2012

CUSTOM SEARCH ,CUSTOM LIST VIEW / LIST VIEW WITH IMAGES IN ANDROID WITH SEARCH BAR

               CUSTOM LIST VIEW / LIST VIEW WITH IMAGES IN    ANDROID  WITH SEARCH BAR


















CustomListViewSearch .java




package a.b;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class CustomListViewSearch extends Activity
{
 EditText edittext;
 ListView listview;

 String[] text = {"One", "Two", "Three", "Four", "Five", "Six", "Seven",
   "Eight", "Nine", "Ten", "Algeria", "Argentina", "Australia", 
"Brazil", "Cote d'Ivoire", "Cameroon", 
"Chile", "Costa Rica", "Denmark", 
"England", "France", "Germany",
"Ghana",  "Greece", "Honduras", 
"Italy",  "Japan", "Netherlands",
"New Zealand", "Nigeria", "North Korea",
"Paraguay", "Portugal","Serbia",
"Slovakia", "Slovenia", "South Africa",  
"South Korea",  "Spain", "Switzerland"};

 int[] image = { R.drawable.icon, R.drawable.icon, R.drawable.icon,
   R.drawable.icon, R.drawable.icon, R.drawable.icon, R.drawable.icon,
   R.drawable.icon, R.drawable.icon, R.drawable.icon ,R.drawable.icon, R.drawable.icon, R.drawable.icon,
   R.drawable.icon, R.drawable.icon, R.drawable.icon, R.drawable.icon,
   R.drawable.icon, R.drawable.icon, R.drawable.icon,R.drawable.icon, R.drawable.icon, R.drawable.icon,
   R.drawable.icon, R.drawable.icon, R.drawable.icon, R.drawable.icon,
   R.drawable.icon, R.drawable.icon, R.drawable.icon,R.drawable.icon, R.drawable.icon, R.drawable.icon,
   R.drawable.icon, R.drawable.icon, R.drawable.icon, R.drawable.icon,
   R.drawable.icon, R.drawable.icon, R.drawable.icon};
 int textlength = 0;
 ArrayList<String> text_sort = new ArrayList<String>();
 ArrayList<Integer> image_sort = new ArrayList<Integer>();

 public void onCreate(Bundle savedInstanceState)
 {

  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  edittext = (EditText) findViewById(R.id.EditText01);
  listview = (ListView) findViewById(R.id.ListView01);
  listview.setAdapter(new MyCustomAdapter(text, image));
  
  edittext.addTextChangedListener(new TextWatcher()
  {

   public void afterTextChanged(Editable s)
   {

   }

   public void beforeTextChanged(CharSequence s, int start,
    int count, int after)
   {

   }

   public void onTextChanged(CharSequence s, int start,
    int before, int count)
   {

    textlength = edittext.getText().length();
    text_sort.clear();
    image_sort.clear();

    for (int i = 0; i < text.length; i++)
    {
     if (textlength <= text[i].length())
     {
      if (edittext.getText().toString().
   equalsIgnoreCase((String) text[i].subSequence(0, textlength)))
      {
       text_sort.add(text[i]);
       image_sort.add(image[i]);
      }
     }
    }

    listview.setAdapter(new MyCustomAdapter
     (text_sort, image_sort));

   }
  });
 }

 class MyCustomAdapter extends BaseAdapter
 {

  String[] data_text;
  int[] data_image;

  MyCustomAdapter()
  {

  }

  MyCustomAdapter(String[] text, int[] image)
  {
   data_text = text;
   data_image = image;
  }
  
  MyCustomAdapter(ArrayList<String> text, ArrayList<Integer> image)
  { 
  
   data_text = new String[text.size()];
   data_image = new int[image.size()];

   for(int i=0;i<text.size();i++)
   {
    data_text[i] = text.get(i);
    data_image[i] = image.get(i);
   }

  }

  public int getCount()
  {
   return data_text.length;
  }

  public String getItem(int position)
  {
   return null;
  }

  public long getItemId(int position)
  {
   return position;
  }

  public View getView(int position, View convertView, ViewGroup parent)
  {

   LayoutInflater inflater = getLayoutInflater();
   View row;

   row = inflater.inflate(R.layout.listview, parent, false);

   TextView textview = (TextView) row.findViewById(R.id.TextView01);
   ImageView imageview = (ImageView) row
     .findViewById(R.id.ImageView01);

   textview.setText(data_text[position]);
   imageview.setImageResource(data_image[position]);

   return (row);

  }
 }

}

main.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
                android:layout_height="fill_parent">

                <EditText android:id="@+id/EditText01"
android:layout_height="wrap_content"
                                android:layout_width="fill_parent"
android:hint="Search films">                               
                </EditText>

                <ListView android:id="@+id/ListView01"
android:layout_height="wrap_content"
                                android:layout_width="fill_parent">
</ListView>

</LinearLayout>


listview.xml





<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_height="wrap_content"
android:gravity="left|center"
                android:layout_width="fill_parent"
android:paddingBottom="5px"
                android:background="#00000000"
                android:paddingTop="5px"
android:paddingLeft="5px">

                <ImageView android:id="@+id/ImageView01"
                                android:layout_width="wrap_content"
android:layout_height="wrap_content">
                </ImageView>

                <TextView android:id="@+id/TextView01"
                                android:layout_width="wrap_content"
android:layout_height="wrap_content"
                                android:textSize="20px"
                                android:textStyle="bold"
                                android:layout_marginLeft="10px"
android:textColor="#0099CC">
                </TextView>

</LinearLayout>





output




























Saturday, 2 June 2012

access facebook and google using intenttab

access facebook and google using intent tab



Here is a good example for how to access Facebook or Google using intent tab,here we simply uses the intent concept.it a simple example  for beginners.


class PeeractivityActivity.java



package a.b;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;

public class PeeractivityActivity extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        TabHost host=getTabHost();
        host.addTab(host.newTabSpec("one").setIndicator("facebook").setContent(new Intent(this, facebook.class)));
        host.addTab(host.newTabSpec("two").setIndicator("google").setContent(new Intent(this, google.class)));
    }


}

facebook .java



package a.b;


import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class facebook extends Activity {
WebView browser;

@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);

browser=new WebView(this);
setContentView(browser);
browser.loadUrl("http://www.facebook.com/");
}
}


google.java




package a.b;
import android.app.Activity;

import android.os.Bundle;

import android.webkit.WebView;

public class google extends Activity {
WebView browser;

@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);

browser=new WebView(this);
setContentView(browser);
browser.loadUrl("https://www.google.co.in/");
}
}

Friday, 1 June 2012

sample output for the implicit intent program




Implicit intent example


Implicit intent example



intentexampleactivity.java


package a.b;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class IntentexampleActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ViewContacts();
    }

private void ViewContacts() {
// TODO Auto-generated method stub
try
{
Button b1=(Button)findViewById(R.id.b1);
b1.setOnClickListener(new OnClickListener() {



@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent contacts =new Intent();
contacts.setAction(android.content.Intent.ACTION_VIEW);
contacts.setData(ContactsContract.Contacts.CONTENT_URI);
startActivity(contacts);

}
});
}
catch (ActivityNotFoundException anfe) {
Log.e("view contacts","viewing of contacts failed",anfe);
// TODO: handle exception
}
}
}



main.xml





<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    />
<Button android:id="@+id/b1"
android:layout_height="wrap_content"
android:layout_width="228dp"
android:text="view contacts"
android:layout_gravity="center_horizontal">
</Button>
</LinearLayout>




Example for main.java



package intentcalculator.i;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class IntentcalculatorActivity extends Activity implements OnClickListener{
    /** Called when the activity is first created. */

TextView wel;
Button cal;



    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        wel=(TextView) findViewById(R.id.wel);
        cal=(Button) findViewById(R.id.cal);
       
        cal.setOnClickListener(this);
       
       
       
    }

public void onClick(View v) {
// TODO Auto-generated method stub
Intent i=new Intent(this,calc.class);
startActivity(i);

}
}

Example for R.java file


Example for R.java file



/* AUTO-GENERATED FILE.  DO NOT MODIFY.
 *
 * This class was automatically generated by the
 * aapt tool from the resource data it found.  It
 * should not be modified by hand.
 */

package a.b;

public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int icon=0x7f020000;
    }
    public static final class id {
        public static final int button1=0x7f050002;
        public static final int relativeLayout1=0x7f050000;
        public static final int textView1=0x7f050001;
    }
    public static final class layout {
        public static final int main=0x7f030000;
    }
    public static final class string {
        public static final int app_name=0x7f040001;
        public static final int hello=0x7f040000;
    }
}

Example for string.xml file


Example for string.xml file



<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">Hello World, LayoutexampleActivity!</string>
    <string name="app_name">Layoutexample</string>
</resources>

Example for manifest file


Example for manifest file



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="a.b"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".LayoutexampleActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>

Android simple programs.


Android  simple programs.



<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayout1"
    android:layout_height="fill_parent"
    android:background="@drawable/icon"
    android:layout_width="fill_parent">
        <LinearLayout android:orientation="vertical"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:id="@+id/linearLayout1"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
         android:layout_marginLeft="93dp">
         </LinearLayout>
        <ImageView android:src="@drawable/icon"
         android:layout_height="wrap_content"
         android:layout_width="wrap_content"
         android:id="@+id/imageView1"
         android:layout_alignParentTop="true"
         android:layout_alignParentLeft="true"
         android:layout_marginLeft="17dp"
         android:layout_marginTop="46dp"></ImageView>
        <ImageButton android:src="@drawable/icon"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:id="@+id/imageButton1"
        android:layout_below="@+id/imageView1"
        android:layout_toRightOf="@+id/linearLayout1"
        android:layout_marginLeft="33dp"></ImageButton>
        <MediaController android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:id="@+id/mediaController1"
        android:layout_below="@+id/imageButton1"
         android:layout_toRightOf="@+id/imageView1"
          android:layout_marginTop="32dp"></MediaController>
        <VideoView android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:id="@+id/videoView1"
        android:layout_alignParentTop="true"
         android:layout_toLeftOf="@+id/imageView1"></VideoView>
        <TimePicker android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:id="@+id/timePicker1"
         android:layout_below="@+id/linearLayout1"
         android:layout_centerHorizontal="true"></TimePicker>
        <Gallery android:layout_height="wrap_content"
         android:layout_width="match_parent"
         android:id="@+id/gallery1"
         android:layout_alignBottom="@+id/mediaController1"
         android:layout_toRightOf="@+id/mediaController1"
          android:layout_marginLeft="14dp"></Gallery>
    </RelativeLayout>

android layout

android layout


there are 5 types of layouts in android


  • linear layout
  • relative layout
  • table layout
  • scroll view
  • list view 
  • head view
  • web view
  • map view 
  • these are the 5 types of layout