Blog purpose for android basic example for android app developer. any query please my contact

Tuesday 7 March 2023

what is adapter in android

 what is adapter in android


In Android, Adapter is a bridge between UI component and data source that helps us to fill data in UI component. It holds the data and send the data to an Adapter view then view can takes the data from the adapter view and shows the data on different views like as ListView, GridView, Spinner etc. For more customization in Views we uses the base adapter or custom adapters.


An adapter basically connects the User Interfaces and the Data Source. According to Android officials, “An Adapter object acts as a bridge between an AdapterView and the data for that view. Android Adapters basically provides access to the data items



What is use adapter in Android?

In Android, whenever we want to bind some data which we get from any data source (e.g. ArrayList, HashMap, SQLite, etc.) with a UI component(e.g. ListView, GridView, etc.) then Adapter comes into the picture. Basically Adapter acts as a bridge between the UI component and data sources.



Example Adapter:


public class CustomAdapter extends BaseAdapter {


@Override

public int getCount() {

return 0;

}


@Override

public Object getItem(int i) {

return null;

}


@Override

public long getItemId(int i) {

return 0;

}


@Override

public View getView(int i, View view, ViewGroup viewGroup) {


return null;

}

No comments:

Post a Comment