2013-03-22 49 views
0

我有一個問題,我有一個類,我想從這個類的文本到textActivity的mainActivity。有人能幫我嗎 ?我想打電話給它的文本視圖上主,我試過,但沒有奏效我們能做些什麼來從這段代碼中設置文本?

private String title; 
    private String test1; 
    private String Time; 
    private String test2; 
    private String report; 

    enter code here 
    public String getTime() { 
     return Time; 
    }  
    public void setTime(String time) { 
     Time = time; 
    } 
    public String getScore() { 
     return test2; 
    } 
    public void setScore(String score) { 
     this.test2 = score; 
    } 
    public String getReport() { 
     return report; 
    } 
    public void setReport(String report) { 
     this.report = report; 
    } 
    public String getTitle() { 
     return title; 
    } 
    public void setTitle(String title) { 
     this.title = title; } 
+1

和你嘗試過什麼?在這裏添加你的Activity類的代碼。 – Sajmon 2013-03-22 10:09:19

+0

請參閱本教程http://developer.android.com/training/basics/firstapp/building-ui.html – 2013-03-22 10:10:39

回答

0

您只需使用String類的公共方法來設置文本到您的TextView。例如:

textViewScore.setText(yourClass.getScore()); 
0

在mainActivity做到這一點:

textViewTime.setText(yourClass.getTime()); 
textViewScore.setText(yourClass.getScore()); 
textViewReport.setText(yourClass.getReport()); 
textViewTitle.setText(yourClass.getTitle()); 
1

試試這個

public void settextManually(int resourceId,String textsethere) 
    View view = findViewById(resourceId); 
    if (view instanceof TextView) { 
     TextView text = (TextView) view; 
      text .setText(textsethere)); 

    }