2012-01-08 3 views
0

TextView의 텍스트를 정수로 변경하면 표시 될 때 페이지에 번호가 표시됩니다.TextView를 Int 값으로 변경

현재 TextView에는 "VALUEFROMfirstResult"라고 나와 있습니다. 예를 들어 firstResult의 정수로 변경하고 싶습니다. 생성 된 정수가 23이라면, TextView는 앞서 언급 한 것 대신 23을 말할 것입니다.

public class Second extends Activity{ 

    TextView reslt; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     // TODO Auto-generated method stub 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.second); 
    } 

    public static void insert(int firstResult2) { 
     // TODO Auto-generated method stub 
     reslt = (TextView) findViewById(R.id.tvResult); 

어떻게하면됩니까?

답변

0

또는

reslt.setText(firstResult2 + ""); 
+0

나는이 명령은 메모리에 3 문자열 ","문자열과 연결로 firstResult2의 rappresentation를 만들 것이라고 생각합니다. 그래서 내 솔루션은 조금 더 나은 메모리에만 1 문자열 만들기 때문에 – StErMi

+0

매력처럼 작동! 정적이 아닌 정적으로 삽입 할 수 있도록 그래서 "TextView reslt;"변경했습니다. "정적 TextView reslt;" – MiKenning

+0

너무 복잡해 다른 옵션을 추가하고 싶다고 생각하십시오. – Dante

1

매우 간단 :

reslt.setText(String.valueOf(firstResult2)); 
관련 문제