在我的 MyAdapter 类中,我正在传递(Context context, String[] values)
参数,如下面的代码所示。我想String[] values
在 getView() 方法中使用该变量。无论如何要将此变量传递给 getView() 方法?
class MyAdapter extends ArrayAdapter<String> {
public MyAdapter(Context context, String[] values) {
super(context, R.layout.row_layout_2, values);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater theInflater = LayoutInflater.from(getContext());
View theView = theInflater.inflate(R.layout.row_layout_2, parent, false);
String tvShow = getItem(position);
TextView theTextView = (TextView) theView.findViewById(R.id.textView1);
theTextView.setText(tvShow);
ImageView theImageView = (ImageView) theView.findViewById(R.id.imageView1);
theImageView.setImageResource(R.drawable.dot);
return theView;
}
}