2016-07-21 2 views
0

내 응용 프로그램에 전역 변수를 사용하고 있는데 아래에 변수 myarray를 설정/가져 오는 방법을 알아야합니까?전역 다차원 배열 선언 방법 변수

public class Global extends Application { 
     private String name; 
     private String [][][] myarray=new String[10][10][10]; //<----- 

     public String getName() { 

      return name; 
     } 

     public void setName(String aName) { 
      name = aName; 
     } 

    //<--- set/get for myarray ? 
    } 

내 MainActivity에서 myarray 값을 어떻게 얻을 수 있습니까?

Global g = (Global)getApplication(); 
    String data=g.getName(); 
    g.setName("test"); 
    //<- get/set for myarray ? 

답변

0

배열에 대해 getter setter를 생성해야합니다. 당신이 사용자에게 원할 때마다

그것은 당신이 객체

((ApplicationName) getApplicationContext()).setMyarray(new String[10][10][10]); 
에게 전달해야 세트에 대한

((ApplicationName) getApplicationContext()).getMyarray(); 

전화