Open an activity within another activity

0

How can I create one options activity within another like this one? or I think it's a theme, what is it?

    
asked by Nick Ledesma 31.01.2018 в 18:29
source

1 answer

-1

I know two ways to do it: the first, if you want it to be an activity that is opened, you have to create a style whose parent is a dialog alert and apply it to your activity in the manifest

 <activity
        android:name="Activity"
        android:theme="@style/customDialog" />

 <style name="customDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="windowNoTitle">true</item>
        <item name="colorAccent">@color/colorPrimary</item>
        <item name="android:textColorPrimary">@color/colorNegro</item>
        <item name="android:windowBackground">@android:color/transparent</item>
 </style>

The second option that seems best to me is to do it through a personalized dialogue. For example, a dialogue with a message and a button would be like this

public class CustomDialog extends Dialog {

Button button;
TextView textview;


private View view;


public CustomDialog (Context context, Activity activity, String message, String text_button){
    super(context);

    view = LayoutInflater.from(context).inflate(R.layout.custom_dialog, null);
    getWindow().setBackgroundDrawable(context.getResources().getDrawable(R.drawable.transparent_back));
    setContentView(view);

    button = (Button) view.findViewById(R.id.button);
   textview = (TextView) view.findViewById(R.id.textview);

    setDataOnWidgets(message,text_button);

}

public void setDataOnWidgets(String message, String text_button){
    textview.setText(message);
    button.setText(text_button);

}



public void setButton(View.OnClickListener listener){
    button.setOnClickListener(listener);

}

}

Then in your activity, create and show the dialogue;

final CustomDialog dialog = new CustomDialog(
                Activity.this,
                Activity.this,
                message,
                text_button);

        alert.setCancelable(false);
        alert.setButton(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

        alert.show();
    
answered by 31.01.2018 в 19:44