마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

append 기능 질문드립니다.

0 추천

if(v.getId()==R.id.button4){
        

        }

 

 

 

 

버튼 4를 누르고

 

1이라는 숫자가 입력되어있으면 바로 뒤에 똑같이 1이 붙게해주는

 

예를 들어 11<-이렇게 1뒤에 바로 1이 붙는

 

append 코딩을 모르겠어요.

 

아시는 분 답변부탁드립니다@ ㅠ ㅠ

 

 

  try {
            in = openFileInput(LOCAL_FILE);
        }catch (FileNotFoundException e){

            in = getResources().openRawResource(R.raw.data);
        }

        editText01 = (EditText)findViewById(R.id.editText); //editText.레이아웃 연결.

        try {
            reader = new BufferedReader(new InputStreamReader(in,"UTF-8"));
            String s;
            while ( (s = reader.readLine()) != null) { //한 줄씩 읽어서 처리.
                editText01.append(s); //s 객체를 첨부
                editText01.append("\n");

            }

        }catch (IOException e){

            Log.e("LOCAL_FILE",e.getMessage());
        }

        }

 

    @Override
    public void onClick(View v) {

    if(v.getId() == R.id.button2){
        editText01.setText(""); //텍스트 초기화

    }
        if(v.getId() == R.id.button3){
            finish(); //종료.
        }
    if(v.getId() ==R.id.button){

        editText01 = (EditText)findViewById(R.id.editText);// editText에 레이아웃 연결
        String s = editText01.getText().toString(); //텍스트 추출
        if(s.length() == 0){
            deleteFile(LOCAL_FILE);
            return;

        }
        try{
            OutputStream out = openFileOutput(LOCAL_FILE,MODE_PRIVATE);
            PrintWriter writer = new PrintWriter(new OutputStreamWriter(out,"UTF-8")); //특정한 문자단위 작성
            writer.append(s);
            writer.close();

        }
        catch (IOException e){
            Log.e("Local File", e.getMessage());
        }

 

        if(v.getId()==R.id.button4){
           

        }
    }

    }

 

 

그리고  주석 처리 해주실 수 있으신가요?

 

제가 안드로이드 처음시작하는데 이해하기 어렵네요....

 

제가 몇개는 주석처리해서 써놓긴 했는데 맞는 지 모르겠습니다.

 

혹시 틀리다면 보완할점과 추가설명도 부탁드립니다 ㅠㅠ

you567 (150 포인트) 님이 2015년 4월 19일 질문

1개의 답변

0 추천
 
채택된 답변
if(v.getId()==R.id.button4)
{
  if (editText01.getText().toString().contains("1")}
    editText01.append("1");
}

 

쎄미 (162,410 포인트) 님이 2015년 4월 20일 답변
you567님이 2015년 4월 20일 채택됨
if (editText01.getText().toString().contains("1"))
                editText01.append("1");


그대로 버튼 안에 넣어줬는데 아무 반응이없네요 ㅠㅠ
...