G
G
goodTimes2017-03-17 19:38:34
Java
goodTimes, 2017-03-17 19:38:34

Is the adapter created correctly?

public class CustomAdapter extends BaseAdapter {
    private Context context;
    private String[] stringValues;
    LayoutInflater lInflater;

    public CustomAdapter(Context context, String[] stringValues)
    {
        this.context = context;
        this.stringValues = stringValues;
        lInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = convertView;
        if (view == null) {
            view = lInflater.inflate(R.layout.item, parent, false);
        }
        TextView textView = (TextView) view.findViewById(R.id.colors);
        LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.llColors);
        textView.setText(stringValues[position]);
        return view;
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rou1997, 2017-03-17
@Rou1997

Is the adapter created correctly?

Your code does not work, and you are still asking if it is correct ...
setAdapter(adapter)remember?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question