Skip to content

Instantly share code, notes, and snippets.

@oha-yashi
Last active February 25, 2021 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oha-yashi/9b9f47cbc9a4ccc0c65fb458fef9a898 to your computer and use it in GitHub Desktop.
Save oha-yashi/9b9f47cbc9a4ccc0c65fb458fef9a898 to your computer and use it in GitHub Desktop.
OnlyDialog.app
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.onlydialog">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.OnlyDialog">
<activity
android:name=".MainActivity"
android:theme="@style/Theme.AppCompat.Light.Dialog.Alert">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
package com.example.onlydialog;
import android.os.Bundle;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AlertDialog;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
//setContentView(何もセットしない);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
String dialog_title = "Dialog w/o Activity UI";
String dialog_message = "実験は";
builder.setTitle(dialog_title)
.setMessage(dialog_message)
.setPositiveButton("成功だ!", (dialogInterface, i) -> {
Toast.makeText(this, "success!", Toast.LENGTH_SHORT).show();
finish();
})
.setNegativeButton("失敗だ!", (dialogInterface, i) -> {
Toast.makeText(this, "failure!", Toast.LENGTH_SHORT).show();
finish();
})
.show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment