-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomlistadapter.java
More file actions
38 lines (28 loc) · 1.22 KB
/
Copy pathCustomlistadapter.java
File metadata and controls
38 lines (28 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.example.android.break2;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class Customlistadapter extends ArrayAdapter {
//to reference the Activity
private final Activity context;
//to store the list of countries
private final String[] nameArray;
public Customlistadapter(Activity context, String[] nameArrayParam){
super(context,R.layout.istitems_rowview , nameArrayParam);
this.context=context;
this.nameArray = nameArrayParam;
}
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater=context.getLayoutInflater();
View rowView=inflater.inflate(R.layout.istitems_rowview, null,true);
//this code gets references to objects in the listview_row.xml file
TextView nameTextField = (TextView) rowView.findViewById(R.id.textView13);
//this code sets the values of the objects to values from the arrays
nameTextField.setText(nameArray[position]);
return rowView;
};
}