I am trying to re-use an already created layout xml file in another xml file by means of
My current XML file is as below:
<?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>
The layout file activity_edit_screen has a button named "Update", I want to change that button to "Add". That is the only change between the two xml files. How can I achevie this? I am trying to re-use one xml in another. Please provide suggestions. Thanks in advance.
Try to rename the button in code behind.
Button button=(Button)findViewByID(R.id.button1);
button.setText("Add");
Try to rename the button text in onCreate() after initializing view.
Button sample_btn=(Button)findViewById(R.id.sample_btn);
sample_btn.setText("Add")
;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.