Android 我们可以为include标记中的视图更改布局xml文件中的视图吗。

Android 我们可以为include标记中的视图更改布局xml文件中的视图吗。,android,xml,Android,Xml,我试图通过以下方式在另一个xml文件中重新使用已创建的布局xml文件: 我当前的XML文件如下所示: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_par

我试图通过以下方式在另一个xml文件中重新使用已创建的布局xml文件: 我当前的XML文件如下所示:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include
        android:id="@+id/insertTask"
        layout="@layout/activity_edit_screen">

    </include>

</RelativeLayout>


布局文件活动编辑屏幕有一个名为“更新”的按钮,我想将该按钮更改为“添加”。这是两个xml文件之间唯一的变化。我该怎么做?我试图在另一个xml中重复使用一个xml。请提供建议。提前谢谢

尝试在代码隐藏中重命名按钮

Button button=(Button)findViewByID(R.id.button1);
            button.setText("Add");

初始化视图后,尝试重命名onCreate()中的按钮文本

Button sample_btn=(Button)findViewById(R.id.sample_btn);
sample_btn.setText("Add")

)

在运行时更改它。看答案。谢谢。是的,我做了。好的。谢谢。这起作用了。由于这是我第一次遇到这种情况,我没有朝这个方向思考。谢谢。是的,我也这么做了。谢谢对不起,我不能接受我觉得有两个答案。我可以吗?