I want to display certain content on a section if the user is logged in. However, if the user isn’t logged in, I would like to show a dialog prompting the user to login. I would also like to display the facebook login button inside this dialog.
However, the login button inside the dialog doesn’t seem to work. And when I place it inside the activity layout, it does work.
Is there a way to make it function correctly inside the dialog?
Here is the dialog xml:
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/heart"
android:layout_width="80dp"
android:layout_height="70dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="70dp"
android:background="@drawable/favorite_dialog"/>
<TextView
android:id="@+id/question_favorites"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:layout_below="@+id/heart"
android:layout_marginTop="10dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="20dp"
android:layout_centerHorizontal="true"
android:textStyle="bold"
android:textSize="20sp"/>
<TextView
android:id="@+id/explanation_favorites"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:layout_below="@+id/question_favorites"
android:layout_marginTop="20dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:textSize="18sp"
android:textStyle="italic"
android:layout_centerHorizontal="true"/>
<com.facebook.widget.LoginButton
android:id="@+id/authButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_above="@+id/button"
android:layout_centerHorizontal="true"
/>
<Button
android:id="@+id/button"
android:layout_height="40dp"
android:layout_width="200dp"
android:text="Cancelar"
android:textStyle="bold"
android:textSize="18sp"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="30dp"
android:background="@drawable/cancel"/>
</RelativeLayout>
This dialog is shown on the onCreate method, and it contains a cancel button which dismisses it.
I would appreciate any help. Many thanks in advance.
I figured this one out, it was quite simple, but not so elegant.
What I did was to put the facebook login button inside the main layout, hidden. Then, I set up a listener on the dialog button, and inside it I added “facebookLogin.performClick();”.
That redirected the click to the facebook login listener.
Thanks anyways!