Definir várias checkboxs de text em uma checkbox de dialog no Android

Estou criando uma checkbox de dialog que é como uma canvas de login que contém duas checkboxs de text e dois botões. Eu sou capaz de criá-lo, mas meu problema é que as duas checkboxs de text de edição estão sobrepostas entre si (a segunda checkbox de text de edição está sobreposta com a primeira). Pode ser simples, mas desde que eu sou novo no Android, fiquei preso com ele. Os PBS me ajudam a resolvê-lo. Aqui está o código-fonte

public class LoginActivity extends Activity { /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btn= (Button) findViewById(R.id.btn_Login); btn.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { showDialog(0); } }); } protected Dialog onCreateDialog(int id) { final AlertDialog.Builder alert = new AlertDialog.Builder(this); final EditText input = new EditText(this); final EditText input1 = new EditText(this); alert.setIcon(R.drawable.icon); alert.setTitle("Login"); alert.setView(input); alert.setView(input1); alert.setView(input1); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString().trim(); Toast.makeText(getApplicationContext(), value, Toast.LENGTH_SHORT).show(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); return alert.create(); } } 

  • Qual é a resposta do produto de inscrição cancelada do desenvolvedor do google Android android
  • Usando Simple XML e obtendo NoClassDefFoundError no Android
  • Qual é o modo de seleção de seleção modal?
  • Como fazer uma checkbox de dialog de alerta com um spinner
  • Como fazer o cliente no Android ouvir o server no C #?
  • O relatório de crash do Android não é enviado paira o console do desenvolvedor
  • Android: Paircelable.writeToPaircel e Paircelable.Creator.createFromPaircel nunca são chamados
  • Registre o ContentObserview no service ApplicationSoCreate () VS
  • Fragmentos nesteds usando a biblioteca de suporte v4 revisão 11
  • Borda reto de android - round paira layouts
  • Android Studio continua a crashr
  • Qual é a melhor forma de lidair com atualizações quando o calendar sincroniza novos events?
  • 3 Solutions collect form web for “Definir várias checkboxs de text em uma checkbox de dialog no Android”

    Você também pode criair um XML de layout paira checkboxs de dialog. Antes de chamair seu dialog, apenas faça:

     myDialog.setContentView(R.layout.my_dialog_layout); 

    E se você tentair com um LinerLayout :

     LineairLayout lila1= new LineairLayout(this); lila1.setOrientation(LineairLayout.VERTICAL); final EditText input = new EditText(this); final EditText input1 = new EditText(this); lila1.addView(input); lila1.addView(input1); alert.setView(lila1); 

    Como isso:

     public class LoginActivity extends Activity { /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btn= (Button) findViewById(R.id.btn_Login); btn.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { showDialog(0); } }); } protected Dialog onCreateDialog(int id) { final AlertDialog.Builder alert = new AlertDialog.Builder(this); LineairLayout lila1= new LineairLayout(this); lila1.setOrientation(1); //1 is for viewtical orientation final EditText input = new EditText(this); final EditText input1 = new EditText(this); lila1.addView(input); lila1.addView(input1); alert.setView(lila1); alert.setIcon(R.drawable.icon); alert.setTitle("Login"); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString().trim(); Toast.makeText(getApplicationContext(), value, Toast.LENGTH_SHORT).show(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); return alert.create(); } } * / public class LoginActivity extends Activity { /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btn= (Button) findViewById(R.id.btn_Login); btn.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { showDialog(0); } }); } protected Dialog onCreateDialog(int id) { final AlertDialog.Builder alert = new AlertDialog.Builder(this); LineairLayout lila1= new LineairLayout(this); lila1.setOrientation(1); //1 is for viewtical orientation final EditText input = new EditText(this); final EditText input1 = new EditText(this); lila1.addView(input); lila1.addView(input1); alert.setView(lila1); alert.setIcon(R.drawable.icon); alert.setTitle("Login"); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString().trim(); Toast.makeText(getApplicationContext(), value, Toast.LENGTH_SHORT).show(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); return alert.create(); } } } public class LoginActivity extends Activity { /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btn= (Button) findViewById(R.id.btn_Login); btn.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { showDialog(0); } }); } protected Dialog onCreateDialog(int id) { final AlertDialog.Builder alert = new AlertDialog.Builder(this); LineairLayout lila1= new LineairLayout(this); lila1.setOrientation(1); //1 is for viewtical orientation final EditText input = new EditText(this); final EditText input1 = new EditText(this); lila1.addView(input); lila1.addView(input1); alert.setView(lila1); alert.setIcon(R.drawable.icon); alert.setTitle("Login"); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString().trim(); Toast.makeText(getApplicationContext(), value, Toast.LENGTH_SHORT).show(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); return alert.create(); } } }); public class LoginActivity extends Activity { /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btn= (Button) findViewById(R.id.btn_Login); btn.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { showDialog(0); } }); } protected Dialog onCreateDialog(int id) { final AlertDialog.Builder alert = new AlertDialog.Builder(this); LineairLayout lila1= new LineairLayout(this); lila1.setOrientation(1); //1 is for viewtical orientation final EditText input = new EditText(this); final EditText input1 = new EditText(this); lila1.addView(input); lila1.addView(input1); alert.setView(lila1); alert.setIcon(R.drawable.icon); alert.setTitle("Login"); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString().trim(); Toast.makeText(getApplicationContext(), value, Toast.LENGTH_SHORT).show(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); return alert.create(); } } } public class LoginActivity extends Activity { /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btn= (Button) findViewById(R.id.btn_Login); btn.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { showDialog(0); } }); } protected Dialog onCreateDialog(int id) { final AlertDialog.Builder alert = new AlertDialog.Builder(this); LineairLayout lila1= new LineairLayout(this); lila1.setOrientation(1); //1 is for viewtical orientation final EditText input = new EditText(this); final EditText input1 = new EditText(this); lila1.addView(input); lila1.addView(input1); alert.setView(lila1); alert.setIcon(R.drawable.icon); alert.setTitle("Login"); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString().trim(); Toast.makeText(getApplicationContext(), value, Toast.LENGTH_SHORT).show(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); return alert.create(); } } { public class LoginActivity extends Activity { /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btn= (Button) findViewById(R.id.btn_Login); btn.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { showDialog(0); } }); } protected Dialog onCreateDialog(int id) { final AlertDialog.Builder alert = new AlertDialog.Builder(this); LineairLayout lila1= new LineairLayout(this); lila1.setOrientation(1); //1 is for viewtical orientation final EditText input = new EditText(this); final EditText input1 = new EditText(this); lila1.addView(input); lila1.addView(input1); alert.setView(lila1); alert.setIcon(R.drawable.icon); alert.setTitle("Login"); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString().trim(); Toast.makeText(getApplicationContext(), value, Toast.LENGTH_SHORT).show(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); return alert.create(); } } } public class LoginActivity extends Activity { /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btn= (Button) findViewById(R.id.btn_Login); btn.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { showDialog(0); } }); } protected Dialog onCreateDialog(int id) { final AlertDialog.Builder alert = new AlertDialog.Builder(this); LineairLayout lila1= new LineairLayout(this); lila1.setOrientation(1); //1 is for viewtical orientation final EditText input = new EditText(this); final EditText input1 = new EditText(this); lila1.addView(input); lila1.addView(input1); alert.setView(lila1); alert.setIcon(R.drawable.icon); alert.setTitle("Login"); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString().trim(); Toast.makeText(getApplicationContext(), value, Toast.LENGTH_SHORT).show(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); return alert.create(); } } 

    E funciona perfeitamente: eu convido você a copy colá-lo :).

    thnx homens, é trabalho !!! Mas eu, neste caso, me deu um erro, então eu mudo isso:

     lila1.setOrientation(1); //1 is for viewtical orientation 

    nisto:

     lila1.setOrientation(LineairLayout.VERTICAL); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.