0

我有一个问题,我有一堂课,我想把这个课上的文本放到 textview 上的 mainActivity 中。有人能帮我吗 ?我想在 main 的文本视图中调用它,我试过了,但没有用

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; }
4

3 回答 3

1

尝试这个

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

    }
于 2013-03-22T11:14:57.987 回答
0

只需使用字符串类的公共方法将文本设置到TextView. 例如:

textViewScore.setText(yourClass.getScore());
于 2013-03-22T10:09:56.420 回答
0

在您的 mainActivity 中执行以下操作:

textViewTime.setText(yourClass.getTime());
textViewScore.setText(yourClass.getScore());
textViewReport.setText(yourClass.getReport());
textViewTitle.setText(yourClass.getTitle());
于 2013-03-22T10:15:56.807 回答