mardi 12 juillet 2016

viewing custom listview items in android

when I add the first item it works correctly but when I add the 2nd one it shows listView items' layout but there isn't any data in text box like these pics: ScreenShot 1, ScreenShot 2

My Adapter Code:

public class Myadp extends ArrayAdapter<String> {
private String[] data;
Context context;
private static LayoutInflater inflater = null;
public Myadp(Context context, int resource, int textViewItem, String[] strings) {
    super(context, resource, textViewItem, strings);
    this.data = strings;
    this.context = context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View row = inflater.inflate(R.layout.listtemp, null, true);
    TextView textView = (TextView) row.findViewById(R.id.textView2);
    textView.setText(this.data[position]);
    return row;
}}

Aucun commentaire:

Enregistrer un commentaire