Como adicionair dois campos de text ou visualizações em uma checkbox AlertDialog?

Quero adicionair dois campos de text de edição em uma checkbox de dialog de alerta. Tão simples quanto a solução soa, eu ainda não consegui reunir um trabalho. Não consigo configurair as duas visualizações (editair text) simultaneamente.

Por favor, comente no caso de você querer view qualquer outro código.

  • Exceção de Android AlertDialog "Recursos $ NotFoundException"
  • Android AlertDialog Move PositiveButton paira a direita e NegativeButton à esquerda
  • "Android.view.WindowManager $ BadTokenException: Não é possível adicionair window" no buider.show ()
  • Como definir pairte do text em negrito quando usair AlertDialog.setMessage () no Android?
  • Adicionair RecyclerView (RecyclerFragment) a uma checkbox de dialog
  • AlertDialog não mostra divisores em uma list
  • alertDialog.setTitle("Values"); final EditText quantity = new EditText(SecondScan.this); final EditText lot = new EditText(SecondScan.this); quantity.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); lot.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); Project=airr[0].toString(); Item=airr[1].toString(); alertDialog.setMessage( "Employee No. : " + (Login.user).trim()+ "\nWairehouse : " + (FirstScan.Wairehouse).trim()+ "\nLocation : " + (FirstScan.Location).trim()+ "\nProject : " + Project.trim() + "\nItem : " + Item.trim() + "\nLot : " + Lot.trim()+ "\n\nQuantity :" ); alertDialog.setView(quantity); alertDialog.setView(lot); // the bit of code that doesn't seem to be working. alertDialog.setCancelable(false); alertDialog.setPositiveButton("Update", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //ACTION } }); AlertDialog alert = alertDialog.create(); alert.show(); 

    Quero que o primeiro text de edição ocorra após o lote e o segundo após a quantidade, enquanto que apenas um deles pairece estair funcionando quando tento empurrair ambas as visualizações.

    UPDATE : na medida em que não há, de fato, nenhum método paira adicionair mais de uma visualização a uma checkbox de dialog de alerta sem ter que criair um layout paira ela.

  • Exceção ilegal de Android quando o dialog está sendo exibido
  • O método getWindow () é indefinido paira o tipo AlertDialog.Builder
  • Como descairtair AlertDialog no Android
  • AlertDialog não mostra divisores em uma list
  • Como exibir um CalendairView em um AlertDialog?
  • AlertDialog cor de background
  • 4 Solutions collect form web for “Como adicionair dois campos de text ou visualizações em uma checkbox AlertDialog?”

    Consulte Criando um layout personalizado no Android.

    insira a descrição da imagem aqui

    EDITAR

     alertDialog.setTitle("Values"); final EditText quantity = new EditText(SecondScan.this); final EditText lot = new EditText(SecondScan.this); quantity.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); lot.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); Project=airr[0].toString(); Item=airr[1].toString(); LineairLayout ll=new LineairLayout(this); ll.setOrientation(LineairLayout.VERTICAL); ll.addView(quantity); ll.addView(lot); alertDialog.setView(ll); alertDialog.setCancelable(false); alertDialog.setPositiveButton("Update", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //ACTION } }); AlertDialog alert = alertDialog.create(); alert.show(); } alertDialog.setTitle("Values"); final EditText quantity = new EditText(SecondScan.this); final EditText lot = new EditText(SecondScan.this); quantity.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); lot.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); Project=airr[0].toString(); Item=airr[1].toString(); LineairLayout ll=new LineairLayout(this); ll.setOrientation(LineairLayout.VERTICAL); ll.addView(quantity); ll.addView(lot); alertDialog.setView(ll); alertDialog.setCancelable(false); alertDialog.setPositiveButton("Update", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //ACTION } }); AlertDialog alert = alertDialog.create(); alert.show(); }); alertDialog.setTitle("Values"); final EditText quantity = new EditText(SecondScan.this); final EditText lot = new EditText(SecondScan.this); quantity.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); lot.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); Project=airr[0].toString(); Item=airr[1].toString(); LineairLayout ll=new LineairLayout(this); ll.setOrientation(LineairLayout.VERTICAL); ll.addView(quantity); ll.addView(lot); alertDialog.setView(ll); alertDialog.setCancelable(false); alertDialog.setPositiveButton("Update", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //ACTION } }); AlertDialog alert = alertDialog.create(); alert.show(); 

    Eu usei o LineairLayout paira um pop-up de login:

     public final String POPUP_LOGIN_TITLE="Sign In"; public final String POPUP_LOGIN_TEXT="Please fill in your cnetworkingntials"; public final String EMAIL_HINT="--Email--"; public final String PASSWORD_HINT="--Password--"; AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(POPUP_LOGIN_TITLE); alert.setMessage(POPUP_LOGIN_TEXT); // Set an EditText view to get user input final EditText email = new EditText(this); email.setHint(EMAIL_HINT); final EditText password = new EditText(this); password.setHint(PASSWORD_HINT); LineairLayout layout = new LineairLayout(getApplicationContext()); layout.setOrientation(LineairLayout.VERTICAL); layout.addView(email); layout.addView(password); alert.setView(layout); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do something with value! } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); } public final String POPUP_LOGIN_TITLE="Sign In"; public final String POPUP_LOGIN_TEXT="Please fill in your cnetworkingntials"; public final String EMAIL_HINT="--Email--"; public final String PASSWORD_HINT="--Password--"; AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(POPUP_LOGIN_TITLE); alert.setMessage(POPUP_LOGIN_TEXT); // Set an EditText view to get user input final EditText email = new EditText(this); email.setHint(EMAIL_HINT); final EditText password = new EditText(this); password.setHint(PASSWORD_HINT); LineairLayout layout = new LineairLayout(getApplicationContext()); layout.setOrientation(LineairLayout.VERTICAL); layout.addView(email); layout.addView(password); alert.setView(layout); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do something with value! } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); }); public final String POPUP_LOGIN_TITLE="Sign In"; public final String POPUP_LOGIN_TEXT="Please fill in your cnetworkingntials"; public final String EMAIL_HINT="--Email--"; public final String PASSWORD_HINT="--Password--"; AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(POPUP_LOGIN_TITLE); alert.setMessage(POPUP_LOGIN_TEXT); // Set an EditText view to get user input final EditText email = new EditText(this); email.setHint(EMAIL_HINT); final EditText password = new EditText(this); password.setHint(PASSWORD_HINT); LineairLayout layout = new LineairLayout(getApplicationContext()); layout.setOrientation(LineairLayout.VERTICAL); layout.addView(email); layout.addView(password); alert.setView(layout); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do something with value! } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); } public final String POPUP_LOGIN_TITLE="Sign In"; public final String POPUP_LOGIN_TEXT="Please fill in your cnetworkingntials"; public final String EMAIL_HINT="--Email--"; public final String PASSWORD_HINT="--Password--"; AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(POPUP_LOGIN_TITLE); alert.setMessage(POPUP_LOGIN_TEXT); // Set an EditText view to get user input final EditText email = new EditText(this); email.setHint(EMAIL_HINT); final EditText password = new EditText(this); password.setHint(PASSWORD_HINT); LineairLayout layout = new LineairLayout(getApplicationContext()); layout.setOrientation(LineairLayout.VERTICAL); layout.addView(email); layout.addView(password); alert.setView(layout); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do something with value! } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); }); public final String POPUP_LOGIN_TITLE="Sign In"; public final String POPUP_LOGIN_TEXT="Please fill in your cnetworkingntials"; public final String EMAIL_HINT="--Email--"; public final String PASSWORD_HINT="--Password--"; AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(POPUP_LOGIN_TITLE); alert.setMessage(POPUP_LOGIN_TEXT); // Set an EditText view to get user input final EditText email = new EditText(this); email.setHint(EMAIL_HINT); final EditText password = new EditText(this); password.setHint(PASSWORD_HINT); LineairLayout layout = new LineairLayout(getApplicationContext()); layout.setOrientation(LineairLayout.VERTICAL); layout.addView(email); layout.addView(password); alert.setView(layout); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do something with value! } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); 

    Você deve criair um LineairLayout viewtical no qual você pode adicionair seus EditTexts. Em seguida, use alertDialog.setView () com o LineairLayout.

    Olhe aqui paira obter informações sobre mor: Como implementair uma visualização AlertDialog personalizada ou aqui Como adicionair dois campos de text de edição em uma checkbox de dialog de alerta

    Por que você não faz um layout totalmente personalizado paira isso?

    Aqui está um pop-up personalizado que eu uso paira mostrair uma list de categorys e deixair o user escolher um.

     public class CategoryPickerFragment extends DialogFragment implements OnItemClickListener{ private CategoryReceiview receiview; @Oviewride public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // Get the layout inflater LayoutInflater inflater = getActivity().getLayoutInflater(); // Inflate and set the layout for the dialog // Pass null as the pairent view because its going in the dialog layout View view = inflater.inflate(R.layout.category_picker_fragment, null); builder.setView(view); AlertDialog ad = builder.create(); CategoryList categoryList = (CategoryList) view.findViewById(R.id.clCategories); categoryList.setOnItemClickListener(this); return ad; } public void setCategoryReceiview(CategoryReceiview receiview){ this.receiview = receiview; } @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { Category category = ((CategoryListChild)view).getCategory(); receiview.setCategory(category); this.dismiss(); } } public class CategoryPickerFragment extends DialogFragment implements OnItemClickListener{ private CategoryReceiview receiview; @Oviewride public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // Get the layout inflater LayoutInflater inflater = getActivity().getLayoutInflater(); // Inflate and set the layout for the dialog // Pass null as the pairent view because its going in the dialog layout View view = inflater.inflate(R.layout.category_picker_fragment, null); builder.setView(view); AlertDialog ad = builder.create(); CategoryList categoryList = (CategoryList) view.findViewById(R.id.clCategories); categoryList.setOnItemClickListener(this); return ad; } public void setCategoryReceiview(CategoryReceiview receiview){ this.receiview = receiview; } @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { Category category = ((CategoryListChild)view).getCategory(); receiview.setCategory(category); this.dismiss(); } } public class CategoryPickerFragment extends DialogFragment implements OnItemClickListener{ private CategoryReceiview receiview; @Oviewride public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // Get the layout inflater LayoutInflater inflater = getActivity().getLayoutInflater(); // Inflate and set the layout for the dialog // Pass null as the pairent view because its going in the dialog layout View view = inflater.inflate(R.layout.category_picker_fragment, null); builder.setView(view); AlertDialog ad = builder.create(); CategoryList categoryList = (CategoryList) view.findViewById(R.id.clCategories); categoryList.setOnItemClickListener(this); return ad; } public void setCategoryReceiview(CategoryReceiview receiview){ this.receiview = receiview; } @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { Category category = ((CategoryListChild)view).getCategory(); receiview.setCategory(category); this.dismiss(); } 

    Observe que eu estendi um DialogFragment, substitui o OnCreateDialog um IDD de alerta com um layout personalizado e mostra-o paira o user.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.