我是Android开发新手。我想要一个带有edittExt的多选对话框 。我不想创建ant row.xml。我想在我的多选对话框中添加动态edittext。我不知道该怎么做..如果有人可以帮助我...... 我的多选对话框的代码是....
public class MultiSelectionDialogExample extends Activity
{
protected CharSequence[] _options = { "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune" };
protected boolean[] _selections = new boolean[ _options.length ];
protected Button _optionsButton;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
_optionsButton = ( Button ) findViewById( R.id.button );
_optionsButton.setOnClickListener( new ButtonClickHandler() );
}
public class ButtonClickHandler implements View.OnClickListener {
public void onClick( View view ) {
showDialog( 0 );
}
}
@Override
protected Dialog onCreateDialog( int id )
{
return
new AlertDialog.Builder( this )
.setTitle( "Planets" )
.setMultiChoiceItems( _options, _selections, new DialogSelectionClickHandler() )
.setPositiveButton( "OK", new DialogButtonClickHandler() )
.create();
}
public class DialogSelectionClickHandler implements DialogInterface.OnMultiChoiceClickListener
{
public void onClick( DialogInterface dialog, int clicked, boolean selected )
{
Log.i( "ME", _options[ clicked ] + " selected: " + selected );
}
}
public class DialogButtonClickHandler implements DialogInterface.OnClickListener
{
public void onClick( DialogInterface dialog, int clicked )
{
switch( clicked )
{
case DialogInterface.BUTTON_POSITIVE:
printSelectedPlanets();
break;
}
}
}
protected void printSelectedPlanets(){
for( int i = 0; i < _options.length; i++ ){
Log.i( "ME", _options[ i ] + " selected: " + _selections[i] );
}
}
}
如何在此对话框的每一行中添加edittext ...请大家告诉我正确解决我的问题...
答案 0 :(得分:0)
您需要以编程方式创建视图,如下面的链接所示。
How to create a RelativeLayout programmatically with two buttons one on top of the other?
但是设置了关于活动的视图,你会将值设置为对话框中的公共方法“setview”。