2013-08-19 7 views
0

많은 레이아웃이 있지만 여러 레이아웃의 문자열을 가져 가고 싶습니다. 내 문제가 여기에 .... 내가 얻은 것은 단지 null의편집 텍스트에서 텍스트 가져 오기 다른 레이아웃

내 코드입니다 :

LayoutInflater factory = getLayoutInflater(); 
    View input = factory.inflate(R.layout.activity_inputan, null); 
    View coordinate = factory.inflate(R.layout.activity_location, null); 
    View scan = factory.inflate(R.layout.activity_scan, null); 

    EditText prod = (EditText) input.findViewById(R.id.product); 
    EditText bran = (EditText) input.findViewById(R.id.brand); 
    EditText plac = (EditText) input.findViewById(R.id.place); 
    EditText date = (EditText) input.findViewById(R.id.date); 
    EditText pric = (EditText) input.findViewById(R.id.price); 
    EditText lat = (EditText) coordinate.findViewById(R.id.latitude); 
    EditText longi = (EditText) coordinate.findViewById(R.id.longitude); 
    EditText format = (EditText) scan.findViewById(R.id.format); 
    EditText content = (EditText) scan.findViewById(R.id.content); 

    String a = prod.getText().toString(); 
    String b = bran.getText().toString(); 
    String c = plac.getText().toString(); 
    String d = date.getText().toString(); 
    String e = pric.getText().toString(); 
    String f = lat.getText().toString(); 
    String g = longi.getText().toString(); 
    String h = format.getText().toString(); 
    String i = content.getText().toString(); 

내가 건배를 통해 다른 레이아웃을 보여 주려고하지만 널 (null)입니다. 도움이나 조언을 보내 주시면 감사하겠습니다.

+2

다른 레이아웃에서 무엇을 의미합니까? 같은 '활동'에있는 사람들입니까? 그것들이 같은'Activity'에 없다면. 너는 그렇게 할 수 없다. '활동'이 사라지면 모든 아이들의 의견도 사라집니다. – user2652394

+0

아니요 ... 완전히 다른 활동입니다 .... 그래서, 그럴 수 없습니까? 나는 어떤 방법이 있어야한다고 생각한다. 나는 아직 모른다. .. 대답은 thx이다. –

+1

'Intent # putExtra (id, value)'를 검색하고,'Activity'에서'Intent # getExtraString (id)'로 검색합니다. 희망이 도움이됩니다. – user2652394

답변

0

LayoutInflater를 만듭니다.

LayoutInflater inf = getLayoutInflater(); 
View v1 = inf.inflate(R.layout.regis, null); 
EditText user = (EditText) v1.findViewById(R.id.edt1); 
String usr = user.getText().toString(); 
관련 문제