Android Programming -12 ArrayAdapter

Hı guys in this tutorial  We will see the use of arrayadapters in android programming.

In my previous tutorial, I talked about the  listview component. If you have not read it yet, I recommend you read it first.

If you remember from the previous tutorial, we added the string values we wanted to show in listview into the arraylist. Today we will do the part showing the values we added the arraylist in listview. we will do this with ArrayAdapter.

package com.example.mac.makale;

import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

ListView listView;
ArrayList<String> arrayList;
ArrayAdapter<String> arrayAdapter;

    protected void onCreate(Bundle savedInstanceState) {


arrayList=new ArrayList<>();

      arrayAdapter=new ArrayAdapter<>(YeniSayfaActivity.this,



If we examine the code;

We define te global variables first , then we start writing our code in the oncreate method.We add the string value we want into add into the arraylist, than we define the adapter. we create the adapter with 3 parameter.

The first parameter is the context, the second parameter is the part where the adjustments are made about how each line of the list will appear, and the last part is the part where the arraylist we want to show in listview is specified.

After setting the adapter according to the parameter values mentioned above, we set it with the adapter variable we set thanks to the setAdapter method of listview.

 1,553 views last month,  1 views today

About Kübra Hebeş

Bilgisayar Mühendisi

Leave a Reply