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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay