arraylist에 모든 편집 문구 값을 저장하고 싶지만 지금은 편집자가 입력 한 마지막 값만 저장하고 있습니다. 입력 한 모든 값을 저장하고 싶습니다. 다음과 같이 배열에 글고 치기에 list.My 코드는 다음과 같습니다배열리스트에 모든 edittext 값을 저장하는 방법
ArrayList<String> list = new ArrayList<String>();
list.add(mycartonno.getText().toString());
arraylist에 모든 편집 문구 값을 저장하고 싶지만 지금은 편집자가 입력 한 마지막 값만 저장하고 있습니다. 입력 한 모든 값을 저장하고 싶습니다. 다음과 같이 배열에 글고 치기에 list.My 코드는 다음과 같습니다배열리스트에 모든 edittext 값을 저장하는 방법
ArrayList<String> list = new ArrayList<String>();
list.add(mycartonno.getText().toString());
난 당신이 모든의 OnClick에 새로운 ArrayList를를 만들 생각합니다.
그래서 어쩌면 당신은 당신의 값마다 변화하는 당신의 값을 저장 TextChangedListener를 사용하여 온 클릭ArrayList<String> list = new ArrayList<String>(); // define this is as globally
list.add(mycartonno.getText().toString()); // add this line to where you do your onclick like button
이것은 제가 생각한 것처럼 전역 arraylist를 사용했습니다. arraylist 내부에 값을 추가하기 위해 코드를 변경했습니다. – Sachin
외부/전 세계적으로 당신의 ArrayList를을 만들 수 있습니다.
EditText.addTextChangedListener(new TextWatcher(){
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start, int count, int after){}
public void onTextChanged(CharSequence s, int start, int before, int count){}
});
TextWatcher를 추가해야합니다. 요구 사항에 따라 OnTextChangedListener의 구현 된 메소드에서 list.add()를 호출하십시오.
mEditText.addTextChangedListener(new TextWatcher()
{
@Override
public void afterTextChanged(Editable s) {
//use here if you want to save after a string is typed
list.add(s.toString());
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//use here if you want to save before already present string is changed
list.add(s.toString());
}
@Override
public void onTextChanged(CharSequence s, int start, int before,int count) {
//use here if you want to save all the strings that are typed
list.add(s.toString());
}
};);
이것은 작동하지 않으며 위의 문제가 동일합니다. arraylist 안에 마지막으로 입력 된 edittext 값을 얻고 있습니다. 편집 한 텍스트의 모든 값을 arraylist 안에 저장하고 싶습니다. – Sachin
이 코드를 작성한 방법은 무엇입니까? –
은 매번 arraylist 객체를 생성 할 수 있습니다. 객체를 한 번 만들어야합니다. –
onCreate 메서드를 전역에 배열 목록에 새 값을 할당 한 다음 편집 작업의 데이터를 배열에 추가하면 성능 목록에있는 새 데이터가 새 인덱스에 저장된다는 것을 알 수 있습니다. –