I have two activities/two XMLs.
I made a Facebook button inside signactivty.java
(sign.xml
) and I want to display the Facebook button in homeactivity.java
(home.xml
).
How can I use a button that's created in another activity?
Please give me an example.
create facebook_button.xml like this
<Button xmlns:android="http://schemas.android.com/apk/res/android"
id="@+id/fb_button"
android:layout_width="64dp"
android:layout_height="64dp" />
create sign.xml layout file and use
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/facebook_button"></include>
....
</LinearLayout>
and so, in your home activity too...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/facebook_button"></include>
....
</LinearLayout>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments