Make Follow This Steps: Open Android Studio  :- Step2:-  Step3:- Step4:- Step5: activty_main.xml Code in pasting main.xml </span></...

Muiltiple EditText in CostomDialog in Android Studio

22:35 0 Comments

Make Follow This Steps:



Open Android Studio  :-




Step2:- 


Step3:-

Step4:-






Step5:

activty_main.xml

Code in pasting main.xml

Step6:

costum.xml

Code in pasting costum.xml

Step7:

MainActivity.java

Code in pasting MainActivity.java
package com.neo_istone.muiltipleedittext; import android.content.DialogInterface; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; import org.w3c.dom.Text; public class MainActivity extends AppCompatActivity { private Button btn1; private TextView name,email,age; private AlertDialog.Builder builder; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btn1 = (Button) findViewById(R.id.showme_dialog_box); builder = new AlertDialog.Builder(this); name = (TextView) findViewById(R.id.name); email = (TextView) findViewById(R.id.email); age = (TextView) findViewById(R.id.age); btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { builder.setTitle("MulitipleEditTexts"); final View v2 = (View)getLayoutInflater().inflate(R.layout.coustom_dialog_box,null); builder.setView(v2); final TextView name2 =(TextView) v2.findViewById(R.id.name2); final TextView email2 =(TextView) v2.findViewById(R.id.email2); final TextView ag2 =(TextView) v2.findViewById(R.id.age2); builder.setPositiveButton("Shome Text", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if(name2.getText().toString().equals("")){ name.setText("N/A"); }else { if (email2.getText().toString().equals("")){ email.setText("N/A"); } else { if (ag2.getText().toString().equals("")){ email.setText("N/A"); } else { name.setText(name2.getText().toString()); email.setText(email2.getText().toString()); age.setText(ag2.getText().toString()); } } } } }); builder.show(); } }); } }

App Screenshots:

                                            screnenShot:1

                                                          screnenShot:2

0 Comments: