Tuesday, 5 June 2012

Android listview (cont....)

Firstly my apologies for such delay in publishing the next part of listview and adapter.
Now that we know what the listview is basically used for.Here. We will get acquainted with adapters

Adapters are basically subclasses BaseAdapter or its subclass.they provide incredible flexibility once you understand how it is being used.

Below is the summary how the adapters work

1. Create a layout that you want each of column to have

2. provide data as a cursor or collections of objects that you want the list to have That's it there is nothing else that you need to have

Saturday, 14 April 2012


        Android ListView are probably amongst few of the most used View in Android. They are used to show data as a list of items.These data can have various flavour from the plane oL single line data to complex data with images and Multiple line of data and can even be interactive with use of buttons,checkboxes etc.

        ListView are represented as

        android:id="@+id/YOUR ID  HERE" />
in layout xml

 android:id="@+id/YOUR ID HERE"
helps you to identify your listview from your class(Activity/Dialog/Fragment etc) with the string you get from "YOUR ID HERE"

for eg:.

        Consider an Activity containing a listview as show above layout xml, then it would look something like this in your code

pubic class MyActivity extends Acitity{
    ListView mListVew;
    // some code here
    //You can initialize it as follows
    mListView=(ListView) findViewById(R.id."YOUR ID HERE");

        now we have an instance of listview and ready to fill it with data that we want.
    The process of filling the ListView is called inflating and "Adapters" are used to do these.Adapters basically decide how and what kind of data can a list view display.Adapters are attached to ListView  as follows,

mListView.setAdapter("Name of your adapter");

        These adpater must be child of BaseAdapter or its type.Customizing these adapters gives the magic that you want your ListView to have.