ハーゼン:
私が持っているArray
クラスの一部として、およびそれにアイテムを追加することができますが、私は、クラス自体に直接アイテムを追加したいと思います。それは可能ですか?
public class Buttons {
public Array<SimpleButton> buttons = new Array<SimpleButton>();
}
それから私は、このような項目を追加することができます。
buttons.buttons.add(simpButton);
しかし、私はこのように直接アイテムを追加します:
buttons.add(simpButton);
RR_IL:
あなたのクラスに「追加」機能を追加して、クラスオブジェクトを経由して、それを利用することができます
public class Buttons {
public Array<SimpleButton> buttons = new Array<SimpleButton>();
public void add(SimpleButton input){
//Handle invalid input
buttons.add(input);
}
}
それを使用するので、あなたのような何かをするだろう -
Buttons buttonObj = new Buttons();
buttonObj.add(SimpleButtonTmp); //SimpleButtonTmp -> SimpleButton Obj
あなたはこのルートを移動したくないそうでない場合は次の操作を行うことができます -
public class Buttons extends Array<SimpleButton>
そして、あなたは直接のすべての機能にアクセスすることができます
public static void main(String[] args)
{
Buttons myButton = new Buttons();
myButton.*AnyfunctionInArray();
}