2014-01-23 4 views
-2

edittext의 텍스트를 textviews에 입력하고 싶은 경우 'HELLO'을 입력 한 다음 H를 텍스트 뷰로 설정하고 E를 다른 것으로 설정합니다.안드로이드는 edittext 값을 여러 텍스트 뷰로 설정합니다

다음은 Toast 메시지에 텍스트가 하나씩 표시되는 코드입니다.

textview.settext()을 사용하면 앱이 다운됩니다.

button.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      // TODO Auto-generated method stub 
      String s=editText.getText().toString(); 

      char charArray[] = s.toCharArray(); 


      for(int i=0;i<charArray.length;i++){ 

       char r=charArray[i]; 

       Toast.makeText(getApplicationContext(), ""+r, Toast.LENGTH_LONG).show(); 

      } 

     } 
    }); 
+0

어떤 오류가 발생합니까? 그 인덱스는 outOfBound입니까? – Saqib

+1

더 관련성이 높은 코드로 logcat 오류를 게시하십시오. – GrIsHu

답변

1

난 당신이 다음과 같이 뭔가를해야한다고 생각 :

ArrayList<TextView> tvList = new ArrayList<TextView>(); 
     String str = "hello"; 
     for(int i=0 ;i<tvList.size() ; i++){ 
      tvList.get(i).setText(str.charAt(i)+""); 
     } 

당신이 내가 menthoind으로 수행 한 후, 목록에서 textviews을 저장 일을해야한다.

희망이 있습니다.

+0

'Text Exception에'char '을 설정할 수 없기 때문에'Resource Not Found Exception'가 발생하면 String으로 변환 한 다음 TextView로 설정해야합니다. –

+0

업데이트를 확인하십시오 –

+0

이 질문을하지 않습니다. –

관련 문제