How to call or pop up fragment upon button click
17,582
You need to design another layout only for the pop up to be shown and make it alignparenttop. Here is the example layout
Create new xml file dialogue.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLyt"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#FFFFFF"
android:paddingTop="10dp" >
<TextView
android:id="@+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Fill in your design in this place"
android:textSize="10dp" />
</RelativeLayout>
</RelativeLayout>
Once you have created your design. You need to call it in your onbutton click. Following is the example to show a dialogue
ratingButton.setOnCLickListener(new view.OnCLickListener(){
@Override
public void onCLick(View v){
final Dialog fbDialogue = new Dialog(ProfileActivity.this, android.R.style.Theme_Black_NoTitleBar);
fbDialogue.getWindow().setBackgroundDrawable(new ColorDrawable(Color.argb(100, 0, 0, 0)));
fbDialogue.setContentView(R.layout.facebook_dialogue);
fbDialogue.setCancelable(true);
fbDialogue.show();
}
});
Hey I have put the code in onclicklistener. Check it . The above code works perfectly fine for me. As per my requirement I wanted the dialogue on the bottom of the screen . I have just made few lines of code change above to meet your requirement. My requirement was something like this
Author by