Display button from another activity

senaa

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.

Farrokh

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.

edited at
0

Comments

0 comments
Login to comment

Related

Calling another activity from Button

enable button from another activity

not able to make a button visible from another activity

How to display values passing from one activity in another activity?

How to display text from one activity to another activity layout?

How to display text from one activity to another activity?

How to create button dynamically from one activity to another activity

Display image in another activity after clicking on upload button

How to display back button on action bar in android another activity

Calling an AlertDialog in another class from a button onClick in another Activity

Button is not disabling in another activity

How to display data from an activity to another and in the same time to save it?

Android how to display image in Arraylist which intent from another activity?

How to choose image from gallery and display in another activity android?

How to get data from onitemclick and display it on another activity (Android Dev)?

How to pass int value from one activity to another and display in TextView?

How to display a welcome message including username from another activity in android?

How to display data from asyntask in another activity textviews?

FCM how to display data from notification click in another activity

Display to another activity json array result from onPostExecute

How do I enable a button from another activity using Java?

Android: refresh/update fragment from another activity on button clicked

How to enabled/disabled button based on the result from another activity?

How to get values from a facebook login button and pass it to another activity

How to update recyclerview from another activity (button) JAVA

How to change toggle button state from another activity

How to pass value from fragment button to another activity

Fragment Activity Display Back Button

How to pass a image dynamically from one activity to another activity and display it in imageview through JSON