Saturday, 29 December 2012

How to load a spinner with values from SQlite Database in android?


Here is a simple example showing how to load a database values in a spinner in android.



OK we will start.
This is the layout for the spinner row.
spinner_row.xml




activity_main.xml












Read the complete post here...

http://www.coderzheaven.com/2012/11/18/load-spinner-values-sqlite-database-android/

How to crop an Image in Android?


This is a sample program that launches the camera and crop the captured image.

Check this link to another crop image example.









This is the layout xml.
<strong>activity_main.xml</strong>

[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" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="3dp"
        android:text="@string/intro"
        android:textStyle="bold" />

    <Button
        android:id="@+id/capture_btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/capture" />

    <ImageView
        android:id="@+id/picture"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:contentDescription="@string/picture" />

</LinearLayout>
[/xml]

Now this is the Main Java File that implements the crop functionality.

Read More from here...

http://www.coderzheaven.com/2012/12/15/crop-image-android/

Monday, 24 December 2012

Select an Image from gallery in ANDROID and show it in an ImageView.

Hi all
In this tutorial I will show you how to get an image from your phone gallery and show it in an imageview.
Here we use intents to open up the image gallery and get the image URI.
Here I am setting the image type as “image” to get only the images.
And on onActivityResult if the result is OK, then get the data using getData() function and converting the imageURI to the stringPath.

Read more from here
http://www.coderzheaven.com/2012/04/20/select-an-image-from-gallery-in-android-and-show-it-in-an-imageview/



Saturday, 15 December 2012

Customizing a spinner in android.

Hello everyone.........

 You all knew that a spinner or combobox is an inbuilt widget in android. And Like any other widgets spinners are also customizable. Here is a simple example to customize a spinner. First we will look at the java code. The getView method is called for each row in the spinner. So with the help of an Layout Inflater you can inflate any layout for each row. At extreme you can have each layout for each row. Check these older posts about spinner.

 1. How to get a selected Item from a spinner in ANDROID?
 2. How to set an item selected in Spinner in ANDROID?
 3. How to create a custom ListView in android?

Check out these of ListViews

 1. Simplest Lazy Loading ListView Example in Android with data populated from a MySQL database using php.
 2. How to add checkboxes and radio buttons to ListView in android? OR How to set single choice items in a ListView in android?

 Read complete code from here http://www.coderzheaven.com/2011/07/18/customizing-a-spinner-in-android/

Monday, 5 November 2012

ActionBar with Search Option and other options in Android.


This is the example showing how to start with ActionBar in android.

1. <a href="http://www.coderzheaven.com/2012/01/28/android-removes-the-need-of-menu-button-from-devices-with-actionbar/" title="ActionBar" target="_blank">Android removes the need of Menu button from devices with ActionBar.</a>

2. <a href="http://www.coderzheaven.com/2012/08/23/start-actionbar-android/" title="ActionBar" target="_blank">How to start with ActionBar in Android?</a>

3. <a href="http://www.coderzheaven.com/2012/09/28/dynamically-adding-removing-toggling-removing-actionbar-tabs-android-part-2/" title="ActionBar" target="_blank">Dynamically Adding, Removing, Toggling and Removing all ActionBar Tabs in Android – Part 2?</a>
 

Read complete post from here..

http://www.coderzheaven.com/2012/10/20/actionbar-search-option-options-android/

Saturday, 21 July 2012

How to initialize an ArrayList in Android?


ArrayList<String> images_arr =
new ArrayList<String>(){
private static final long serialVersionUID = -1773393753338094625L;
{
add("string1");
add("string2");
add("string3");
add("string4");
}
};

Wednesday, 4 July 2012

How to delete a contact in android?


Hello all previously I have shown how to list all contacts in your phone and in another post I showed  how to programatically create a contact in android
In today's tutorial I will show you how to delete a contact in android programatically.

This simple code does that.

Read more
http://www.coderzheaven.com/2012/06/23/delete-contact-android/

Thursday, 28 June 2012

How to get a Sprite by tag in Cocos2D ?


Hi,

Sometimes you may need to get a sprite using tag while doing a project using Cocos2D. It's easy to get a sprite by a tag in Cocos2D, use the following code to get it.

[java]tempSprite = (CCSprite*)[self getChildByTag:7];[/java]

Here 'tempSprite' is your CCSprite and it will get the sprite with tag 7.

:)

Tuesday, 19 June 2012

How to explicitly free memory in android OR Release unwanted memory in Android?


public void freeMemory(){
    System.runFinalization();
    Runtime.getRuntime().gc();
    System.gc();
}

Visit http://www.coderzheaven.com/2012/04/24/explicitly-free-memory-android-release-unwanted-memory-android/ for more information.

Saturday, 16 June 2012

Placing Controls in a Widget in Android and Listening to the events from them.


Now in today’s tutorial I am going to show how to place controls like buttons inside the widget and listen to their events and respond to it.


I am proceeding the same as the previous tutorials.
First I will create a new project named “ControlsInWidget” and name the activity “MyActivity.java”.
Now we will create a layout for this main activity. settings.xml
These are the contents of settings.xml
?
1
2
3
4
5
6
7
8
9
10
11
12
13
<TableLayout android:id="@+id/TableLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/tv1"
    android:text="CoderzHeaven Widget Settings Activity"
    android:textColor="@android:color/white"
    android:textSize="15dip"
    android:textStyle="bold"
    android:layout_marginTop="5dip"/>
</TableLayout>

Read the complete post from here.