We are making a dynamic custom array adapter for our android project. Now we need to pass dynamic android layout object and other data source as argument when initialize this custom adapter class. After that everything will be dynamic.
public class CustomAdapterView extends ArrayAdapter<String> {
private Activity context;
private String[] googleProducts;
private String[] productDescription;
private Integer[] productImage;
private Layout listItemLayout;
public CustomAdapterView(Activity context, Layout listItemLayout, String[] googleProducts, String[] productDescription, Integer[] productImage) {
super(context, R.layout.content_custom_listview, googleProducts);
// Tring to do this
//super(context, listItemLayout, googleProducts);
//Error: Cannot resolve method 'super(android.app.Activity, android.text.Layout, java.lang.String[])'
// Set Local Property
this.context = context;
this.googleProducts = googleProducts;
this.productDescription = productDescription;
this.productImage = productImage;
}
Now in the super() method we want to pass dynamic Layout for displaying custom list view.
super(context, listItemLayout, googleProducts);
//Error: Cannot resolve method 'super(android.app.Activity, android.text.Layout, java.lang.String[])'
Than call that from any Activity
// Initialize
ListView lv = (ListView) findViewById(R.id.custom_listview);
Layout dynamicLayout = null;
// Our Custom Adapter Object
CustomAdapterView cav = new CustomAdapterView(this, dynamicLayout, googleProducts, productDescription, productImage);
//Set Adapter
lv.setAdapter(cav);