2010-03-11 58 views
0

嗨,大家好我是看着這個代碼,但IM努力理解super關鍵字做什麼,現在我知道它會調用父類的構造函數,但在這個例子中有犯規似乎是一個超類,以便即時通訊困惑。 所以那裏有在CustomArray的構造函數,然後調用其超不過什麼?的Android的ListView

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"); 



       } 
      }); 

     } 
+0

'customArray'延伸'ArrayAdapter ',所以這是你的超類。 '超(續,_resource,項目)'是調用父類的構造函數,有三個參數。 – 2010-03-11 22:44:32

回答