저는 백엔드 클래스의 뷰인 클래스에서 작업 중이므로 일부 백엔드 클래스 속성을 표시해야합니다.항목을 ArrayList에 유지하십시오.
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.
}
}
내가 궁금해하는 방법, 목록이 비어 있지 않도록 draw()
에 필요한 경우, getInputs()
지속적 내가 만든 객체를 유지하는이 경우?
사용하는 곳에서 관련 코드를 추가하십시오. – BobTheBuilder
getInputs()를 호출 하시겠습니까? 동일한 인스턴스에서 getInputs() 및 draw()를 호출 했습니까? 그것은 "영구적"이어야하기 때문입니다. –
"* 그리고 그것은 0입니다. 항상"draw "가'getInputs' 전에 호출 된 것처럼 보입니다 ...'draw'와'getInputs'를 실행하는 두개의 다른 쓰레드가 있다면 다른 가능성이 있습니다. – assylias