質問

こんにちはみんな、私はこのコードを見ていたが、私はsuperキーワードが何をするかを理解するのに苦労しています。

私はそれがスーパークラスのコンストラクタを呼ぶだろうけど、私は混乱しているように、この例では、スーパークラスがあるように表示されません。

だから、customArrayコンストラクタとその呼び出し元のスーパーが、何にはありますか?

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



                }
           });

      }
役に立ちましたか?

解決

あなたはArrayAdapterないそのよろしいですか?ここにコンストラクタを参照してください: http://developer.android.com/reference/android /widget/ArrayAdapter.htmlする

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top