Monday, 24 May 2010

Custom Adapter


  1. create a class with sub type of BaseAdapter class
  2. it is an  abstract class provide the implementation for all the abstract methods.
  3. setAdapter(new classname()) method is used to set the custom adapter to the UI component
  4. layout InFlatter is a class which is used to create the UI programatically.
steps to write the application:

  • once you create the project in eclipse, go to graphical layout of layout folder:

  • Now click on Composite, next drag the ListView to the screen, then it looks like this

  • Now double click on Listview, and control goes to activity_main.xml, we can see the following code:
<ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
         //you can delete the following below tag
//        android:layout_marginLeft="28dp"
 //       android:layout_marginTop="44dp" > 
        
    </ListView>

  • ere



No comments:

Post a Comment