I want to make a custom adaper which will contain multiple String
and an ArrayList<ArrayList<GeofenceDetails>>
.
private ArrayList<Geofences> geofencesArrayList;
geofencesArrayList = new ArrayList<Geofences>();
assetNameArrayList = new ArrayList<ArrayList<GeofenceDetails>>();
geofencesArrayList.add(new Geofences(id,name,type,assetNameArrayList));
adapter = new GeofenceNameListAdapter(getActivity(),geofencesArrayList);
adapter.notifyDataSetChanged();
geoListView.setAdapter(adapter);
Here is my custom adapter
public class GeofenceNameListAdapter extends ArrayAdapter<ArrayList<Geofences>> {
private final Activity context;
private final ArrayList<Geofences> geofences;
//song list and layout
private LayoutInflater view;
// private static LayoutInflater inflater=null;
public static final String PREFERENCES = "RPREFS";
SharedPreferences sharedprefs = null;
private String ord_id = null;
private String email = null;
public GeofenceNameListAdapter(Activity context,
ArrayList<Geofences> geofences) {
super(context, R.layout.layout_geofence, geofences.size());
// TODO Auto-generated constructor stub
finder_sharedprefs = getContext().getSharedPreferences(PREFERENCES, getContext().MODE_PRIVATE);
finder_ord_id = finder_sharedprefs.getString("org_id", null);
finder_email = finder_sharedprefs.getString("email", null);
this.context = context;
this.geofences = geofences;
}
public View getView(final int position, View view, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View rowView = inflater.inflate(R.layout.layout_geofence, null, true);
TextView txtTitle = (TextView) rowView.findViewById(R.id.name);
TextView txtType = (TextView) rowView.findViewById(R.id.type);rowView.findViewById(R.id.delete);
txtTitle.setText(geofences.get(position).getTitle());
txtType.setText(geofences.get(position).getType());
return rowView;
}
I can see everything on geofencesArrayList
. Here I am printing data of geofencesArrayList
for (int l = 0; l<geofencesArrayList.size(); l++) {
Log.d("GEOFENCE_DETAILS", geofencesArrayList.get(l).getId().toString());
Log.d("GEOFENCE_DETAILS", geofencesArrayList.get(l).getTitle().toString());
Log.d("GEOFENCE_DETAILS", geofencesArrayList.get(l).getType().toString());
// Log.d("GEOFENCE_DETAILS", geofencesArrayList.get(l).getPoints().toString());
Log.d("GEOFENCE_DETAILS", geofencesArrayList.get(l).getEnforcedData().toString());
}
But the problem is Adapter doesn't display any data. I think something went wrong in my custom adapter but I couldn't figure out it.
I appreciate you advice. Let me know How can I create a custom adapter to show multiple strings and ArrayList<ArrayList<>>
.
Thanks in advance.