try to add objects of second list in first on
nomi = new String[res.size()];
for (int i = 0; i < res.size(); i++) {
nomi[i] = res.get(i).getNomignolo() + " " +res.get(i).getFamiglia();
}
//list of object with name and family
create adapter
listAdapter = new ArrayAdapter<String>(HomeActivity.this, R.layout.row, R.id.button3, listaNomi);
mainListView.setAdapter(listAdapter);
you cannot set multiple adapter for one listview.
How to create custom array adapter:
public class CustomAdapter extends ArrayAdapter<Person>{
private final Activity context;
private ArrayList<Person> Items;
public CustomAdapter (Activity context, int layout,ArrayList<Person> persons) {
super(context, layout, carriers);
// TODO Auto-generated constructor stub
this.context = context;
this.Items = persons;
}
static class ViewHolder {
public Button name;
public Button family;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
// Recycle existing view if passed as parameter
// This will save memory and time on Android
// This only works if the base layout for all classes are the same
View rowView = convertView;
if (rowView == null) {
LayoutInflater inflater = context.getLayoutInflater();
rowView = inflater.inflate(R.layout.item, null, true);
holder = new ViewHolder();
holder.name= (TextView) rowView.findViewById(R.id.name);
holder.family= (TextView) rowView.findViewById(R.id.family);
rowView.setTag(holder);
} else {
holder = (ViewHolder) rowView.getTag();
}
holder.name.setText(Items.get(position).getName());
holder.family.setText(Items.get(position).getFamily());
return rowView;
}
}
and create PErson Object:
public class PErson{ public String name; public String family;
public Person();
public String getName(){ return name;}
public String getFamily(){return family;}
}
and this is item xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="wkjdhk"
android:textColor="@color/green"
android:textSize="12sp" />
<Button
android:id="@+id/family"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="wkjdhk"
android:textColor="@color/green"
android:textSize="12sp" />
</RelativeLayout>
this is how to call from activity:
adapter = new MyCustomAdapter(CarrierSummaryActivity.this,nomi,R.layout.item);
mainListView.setAdapter(adapter);