将代码从Java转换为Android Studio(显示值)

将代码从Java转换为Android Studio(显示值),java,android,android-studio,Java,Android,Android Studio,我正在尝试将我的游戏从java转换到Android Studio,以便学习Android开发。但我现在最大的问题是显示价值观 我得到了一些变量,例如:CarMain.main[0] 我用按钮添加值:CarMain.main[0]+=1 在Java中,我显示了如下值: S_MoneyLabel.setText("Money: " + CarMain.main[0]); 例如,产出为:货币:71或货币:5000 现在在Android studio中,我不知道如何显示它。 我正在考虑文本视图选项,

我正在尝试将我的游戏从java转换到Android Studio,以便学习Android开发。但我现在最大的问题是显示价值观

我得到了一些变量,例如:
CarMain.main[0]

我用按钮添加值:
CarMain.main[0]+=1

在Java中,我显示了如下值:

S_MoneyLabel.setText("Money: " + CarMain.main[0]); 
例如,产出为:货币:71或货币:5000

现在在Android studio中,我不知道如何显示它。
我正在考虑文本视图选项,但不知道如何操作。

在布局xml文件中添加文本视图,如下所示:

    <RelativeLayout  
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

<Button
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/button"/>
 </RelativeLayout>
现在,将结果设置为文本视图

    button.setText("Money: " + CarMain.main[0]);

布局xml文件中的附加文本视图,如下所示:

    <RelativeLayout  
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

<Button
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/button"/>
 </RelativeLayout>
现在,将结果设置为文本视图

    button.setText("Money: " + CarMain.main[0]);

嘿也许我不知道该把按钮放在哪里,但它显示了一个错误:无法解析符号“Button”,您需要添加并导入它。也许我不知道该把按钮放在哪里,但它显示了一个错误:无法解析符号“Button”,您需要添加并导入它。