0

大家好,我正在查看这段代码,但我很难理解 super 关键字的作用。

我知道它会调用超类构造函数,但在这个例子中似乎没有超类,所以我很困惑。

所以有customArray构造函数,然后是它的调用 super 但在什么上?

public class customArray extends ArrayAdapter<String> {


 int resource;

 public customArray(Context cont, int _resource, List<String> items) {
      super(cont, _resource, items);
      resource = _resource;

 }

 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
      RelativeLayout rl;

      String prod = getItem(position);
      if (convertView == null) {
           rl = new RelativeLayout(getContext());
           LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
                     Context.LAYOUT_INFLATER_SERVICE);
           vi.inflate(resource, rl, true);
      } else {
           rl = (RelativeLayout) convertView;
      }
      TextView t1 = (TextView) rl.findViewById(R.id.text12);
      t1.setText(prod);
      final Button b1 = (Button) rl.findViewById(R.id.widget29);

      b1.setText("efwrf");

      if (position == 2) {

           b1.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {


                Intent i = new Intent(this.class,Alarm.class);


                startActivity(i);

                //   Alarm al = new Alarm(); //
                     b1.setText("alarm set");



                }
           });

      }
4

1 回答 1

0

你确定它不是 ArrayAdapter 吗?请参阅此处的构造函数:http: //developer.android.com/reference/android/widget/ArrayAdapter.html

于 2010-03-11T22:44:07.787 回答