Android ListView Custom ArrayAdapter
-
19-09-2019 - |
Question
Hi guys I was looking at this code but I'm struggling to understand what the super keyword does.
I know it would call the super class constructor, but in this example there doesn't appear to be a super class so I'm confused.
So there is the customArray
constructor and then its calling super but on what?
public class customArray extends ArrayAdapter<String> {
int resource;
public customArray(Context cont, int _resource, List<String> items) {
super(cont, _resource, items);
resource = _resource;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
RelativeLayout rl;
String prod = getItem(position);
if (convertView == null) {
rl = new RelativeLayout(getContext());
LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
vi.inflate(resource, rl, true);
} else {
rl = (RelativeLayout) convertView;
}
TextView t1 = (TextView) rl.findViewById(R.id.text12);
t1.setText(prod);
final Button b1 = (Button) rl.findViewById(R.id.widget29);
b1.setText("efwrf");
if (position == 2) {
b1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(this.class,Alarm.class);
startActivity(i);
// Alarm al = new Alarm(); //
b1.setText("alarm set");
}
});
}
Solution
Are you sure its not ArrayAdapter? See the constructors here: http://developer.android.com/reference/android/widget/ArrayAdapter.html
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow