0

バックエンド クラスのビューであり、バックエンド クラス プロパティの一部を表示する必要があるクラスに取り組んでいます。

public abstract class AGenericNodeView{
    private ANode fObject;  
    private ArrayList<TInputView> fInputs = null;

    public AGenericNodeView(){
        super();
        this.fInputs = new ArrayList<TInputView>();
    }


    private void getInputs(){
        int num = fObject.getNumInputs(); //Number of inputs
        for (int i = 0; i < num; i++)
        {
            this.fInputs.add(new TInputView());
            this.fInputs.get(i).doSth();  
        }
        //fInputs has now the size num which is greater than 0. 
    }    

   //later I call:
   public draw()
   {
      //...
      log(this.fInputs.size()); //output fInputs.size()
      // and it is 0. Always. 
   }


}

getInputs()必要なときにリストが空にならないように、作成したオブジェクトを永続的に保持する方法があるかどうか疑問に思いますdraw()か?

4

1 に答える 1

1

いくつかの提案:

  1. デバッガーを使用します。

  2. ログインnum_getInputs

  3. ログインSystem.identityHashCode(fInputs)getInputsてログインし、drawそれらが同じであることを確認します。

于 2013-03-14T13:46:54.903 に答える