2013-10-17 2 views
1

나는이 코드를 가지고 :안드로이드 가져 오기 글고 텍스트 프로그래밍

List<EditText> someList = new ArrayList<EditText>(); 

//Let's say we'd like to add 10 EditTexts 
for(int i = 0; i < 10; i++){ 
    EditText t1 = new EditText(); //The EditText you'd like to add to the list 
    t1.setText("lol"); //Give the EditText the value 'lol' 
    someList.add(t1); //Add the EditText to the list 
} 

//Go over the list and get the values 
for(EditText t : someList){ 
    String val = t.getText(); //Get the value for the temp EditText variable t 
} 
내가 인덱스 번호로 ArrayList를 텍스트를 얻을 수있는 방법을 알고 싶습니다

? 같은 : somelist[2]

+0

EditText를 목록에 저장해야합니까? –

답변

3

뭔가 트릭을 수행해야합니다

int index = 2; 
EditText et = someList.get(index); 
Log.d(TAG, et.getText()); 
2

이 시도 :이 같은

EditText t = someList.get(2); 
String text=t.getText().toString(); 
0

EditText text2=someList.get(2); 
0

사용하려고이 :

somelist.get(2); 

두 번째 위치에 편집 문구가 표시됩니다.