DEV Community

Harsha S
Harsha S

Posted on

Day 9 Adapters in Android and Questions

Today I learnt about adapters in android which is used to connect a data source and a view. Here is an example of how to implement a basic adapter.

// adapterview
ListView listview = findViewById(R.id.listview);

//data source 
String[] arr = {"WOW","9","DAYS","OVER"};

//Array Adapter
ArrayAdapter<String> arr_adapter = new ArrayAdapter<>(
this, 
android.R.layout.simple_list_item_activated_1,
arr); 

//connect the view 
listview.setAdapter(arr_adapter);
Enter fullscreen mode Exit fullscreen mode

I also solved some coding questions.
I will make a GitHub repo for my 100 days of code tomorrow.

Top comments (0)