2017-08-21 3 views
-5

この画像は、Playストアからアプリをリラックスディープから取った:このタイプのポップアップダイアログをAndroidで作成するにはどうすればいいですか?

this image took from deep relax app from play store

をどのようにポップアップメニューを作成するのですか?私はフィードバックを提供するようユーザーに依頼するアプリを作成していますか?

+0

使用警告ダイアログ、設定、正、負と中性ボタンが – Redman

+0

あなたは、より具体的に説明してくださいすることができます。私はちょうどアンドロイド開発を始めました。可能であれば、役に立つコードを投稿してください。 –

+0

あなたは、2分以上を過ぎて提案を探し、あなたが今聞いた新しい用語のいくつかを検索することができます。 – GolezTrol

答えて

0

することは、この目的のためのこの使用カスタムダイアログを試してみてください。

このcustom_dialog_layoutのようなレイアウトを作成します。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:padding="10dp" 
    android:text="title" 
    android:textColor="#000" /> 

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:padding="10dp" 
    android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting," /> 


<TextView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:padding="10dp" 
    android:text="description" /> 


<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 

    <Button 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:background="@null" 
     android:id="@+id/btnNotNOw" 
     android:text="not now" 
     android:textColor="#040d28" /> 

    <Button 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="2" 
     android:background="@null" 
     android:text="Never" 
     android:id="@+id/btnNever" 
     android:textColor="#040d28" /> 

    <Button 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="2" 
     android:background="@null" 
     android:text="sure" 
     android:id="@+id/btnSure" 
     android:textColor="#040d28" /> 

</LinearLayout> 

</LinearLayout> 

は今のコードの下に使用してダイアログを作成します。

final Dialog dialog = new Dialog(LoginActivity.this); 
    dialog.setContentView(R.layout.custom_dialog_layout); 
    Button btnNotNOw, btnNever, btnSure; 
    btnNotNOw = (Button) dialog.findViewById(R.id.btnNotNOw); 
    btnNever = (Button) dialog.findViewById(R.id.btnNever); 
    btnSure = (Button) dialog.findViewById(R.id.btnSure); 
    Window window = dialog.getWindow(); 
    window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); 
    window.setGravity(Gravity.BOTTOM); 
    dialog.show(); 

    btnNever.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      // perform your action here 
     } 
    }); 
    btnNotNOw.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      // perform your action here 
     } 
    }); 
    btnSure.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      // perform your action here 
     } 
    }); 
0

あなたがカスタムして作成することができますダイアログ:

Cカスタムダイアログ:

このためには、xmlファイルを1つ作成して添付する必要があります。

final Dialog dialog1 = new Dialog(LabCheckOutActivity.this); 
       dialog1.requestWindowFeature(Window.FEATURE_NO_TITLE); 
       dialog1.setCancelable(true); 
       dialog1.setContentView(R.layout.dialog_patient_details); 
       dialog1.show(); 
0
AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this); 

       // Setting Dialog Title 
       alertDialog.setTitle("Top Heading"); 

       // Setting Dialog Message 
       alertDialog.setMessage("Message"); 

       // Setting Positive "Yes" Button 
       alertDialog.setPositiveButton("Sure", new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int which) { 
        // User pressed YES button. Write Logic Here 
        Toast.makeText(getApplicationContext(), "You clicked on Sure", 
             Toast.LENGTH_SHORT).show(); 
        } 
       }); 

       // Setting Negative "NO" Button 
       alertDialog.setNegativeButton("Not Now", new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int which) { 
        // User pressed No button. Write Logic Here 
        Toast.makeText(getApplicationContext(), "You clicked on Not Now", Toast.LENGTH_SHORT).show(); 
        } 
       }); 

       // Setting Netural "Cancel" Button 
       alertDialog.setNeutralButton("Never", new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int which) { 
        // User pressed Cancel button. Write Logic Here 
        Toast.makeText(getApplicationContext(), "You clicked on Never", 
             Toast.LENGTH_SHORT).show(); 
        } 
       }); 

       // Showing Alert Message 
       alertDialog.show(); 
0

チェックこの

AlertDialog.Builder builder = new AlertDialog.Builder(
        MainActivity.this, AlertDialog.THEME_TRADITIONAL); 


      builder.setMessage("Positive,Negative and Neutral Button") 


      builder.setCancelable(false); 


      builder.setTitle("Custom Dialog"); 

      // Set the positive/yes button click listener 
      builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { 
       @Override 
       public void onClick(DialogInterface dialog, int which) { 


       } 
      }); 

      // Set the negative/no button click listener 
      builder.setNegativeButton("No", new DialogInterface.OnClickListener() { 
       @Override 
       public void onClick(DialogInterface dialog, int which) { 

       } 
      }); 

      // Set the neutral/cancel button click listener 
      builder.setNeutralButton("Cancel", new DialogInterface.OnClickListener() { 
       @Override 
       public void onClick(DialogInterface dialog, int which) { 

       } 
      }); 

      AlertDialog dialog = builder.create(); 
      // Display the alert dialog on interface 
      dialog.show(); 
関連する問題