Search Wikipedia

Search results

Dec 17, 2013

Working with Camera in Android

Taking a Picture in Android


Create a new project in Eclipse from File ⇒ New ⇒ Android ⇒ Application Project and fill all the required information. I left my main activity as MainActivity.java

Working with camera needs set of permissions and features in the AndroidManifest.xml file. Add following in your AndroidManifest.xml

android.hardware.camera – Required to use camera hardware
Adding required permissions in manifest file

Dec 10, 2013

Custom Dialog in Android

Creating a Custom Dialog in Android

I create a new android application project called "Custon_dialog"
Then I need to create a custom layout for my custom dialog and for this I create a new xml file called "dialog.xml"
In my custom dialog i want to show a picture and  some texts.
So, i drag a picture in my drawable folder.

dialog.xml


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

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="110dp"
        android:layout_height="160dp"
        android:contentDescription="@string/todo"
        android:padding="20dp"
        android:src="@drawable/android" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="170dp"
        android:layout_height="211dp"
        android:text="@string/i_love_android" 
        android:textSize="25sp"/>

</LinearLayout>

Android Custom ListView With Images And Text

Customizing of ListView 

Today I am gonna customize the listview with images and text.
For this I create a new project called "Listv"
Then I drag a listview in "activity_main" xml file.


This xml file code looks like this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >
    </ListView>
</RelativeLayout>

Dec 5, 2013

Customization of Gridview

Customizing the Gridview 


After completion of simple gridview, now I am going to customize that gridview like opening the full-sized images from gridview and naming the images of the gridview.

For this, i create a new android project called "Grid_cus"
As we have done before, drag the gridview layout in graphical layout as shown below:

Draging Gridview in the layout


As like before tutorial, place the pictures in res->drawable-hdpi folder.
Then  i create a new class called "ImageControl.java" and write these codes :

public class ImageControl extends BaseAdapter{
Context mcontext;

public  static int[] ImageIds= { R.drawable.a, R.drawable.a1,R.drawable.a2, R.drawable.a3,
R.drawable.f, R.drawable.e,R.drawable.a7, R.drawable.a6,R.drawable.a5, R.drawable.a4,R.drawable.r, R.drawable.a1,R.drawable.v};

String texts[] = new String[]{"good","best","bad","damn","lool","joker","hard",
"kool","magic","aaare","pop","rock"};

public ImageControl(Context context){
mcontext = context;
}

Dec 3, 2013

Basic GridView Layout in Android

Creating a Basic GridView Layout in android

 GridView is a viewGroup that displays items in a two-dimensional,scrollable grid. The grid items are automatically inserted to the layout using a ListAdapter.

Today i am gonna create a simple Gridview layout.Now  I prepare images which i want to show in grid layout and place them in res->drawable-hdpi folder.

Images in Drawable-hdpi which will be shown in Gridview

I go to activity_main.xml and drag gridview layout from Palette or I can also write code directly for gridview which will be like this:

activity_main.xml

}