Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中的多重选择对话框中添加editText_Android_Android Edittext_Multi Select - Fatal编程技术网

如何在android中的多重选择对话框中添加editText

如何在android中的多重选择对话框中添加editText,android,android-edittext,multi-select,Android,Android Edittext,Multi Select,我是android开发新手。我想要一个带有edittExt的多重选择对话框 . 我不想创建ant row.xml。我想在我的multiselect对话框中动态添加edittext。我不知道怎么做。。如果有人能帮我。。。 我的多选对话框代码是 public class MultiSelectionDialogExample extends Activity { protected CharSequence[] _options = { "Mercury", "Venus"

我是android开发新手。我想要一个带有edittExt的多重选择对话框 . 我不想创建ant row.xml。我想在我的multiselect对话框中动态添加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] );
            }
        }
    }
公共类MultiSelectionDialogExample扩展活动
{
受保护的CharSequence[]_选项={“水星”、“金星”、“地球”、“火星”、“木星”、“土星”、“天王星”、“海王星”};
受保护的布尔值[]\u选择=新的布尔值[\u options.length];
受保护按钮_选项按钮;
@凌驾
创建时的公共void(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
_选项按钮=(按钮)findViewById(R.id.Button);
_setOnClickListener(新按钮ClickHandler());
}
公共类按钮ClickHandler实现View.OnClickListener{
公共void onClick(视图){
显示对话框(0);
}
}
@凌驾
受保护的对话框onCreateDialog(int id)
{
返回
新建AlertDialog.Builder(此)
.setTitle(“行星”)
.setMultiChoiceItems(_选项、_选择、新对话框选择ClickHandler())
.setPositiveButton(“确定”,新对话框按钮ClickHandler())
.create();
}
公共类DialogSelectionClickHandler实现DialogInterface.OnMultiChoiceClickListener
{
public void onClick(DialogInterface对话框,int单击,布尔选择)
{
Log.i(“我”,_选项[点击]+“选中:”+选中);
}
}
公共类DialogButtonClickHandler实现DialogInterface.OnClickListener
{
public void onClick(DialogInterface对话框,int单击)
{
开关(单击)
{
case DialogInterface.BUTTON_阳性:
printSelectedPlanets();
打破
}
}
}
受保护的空打印选定的行星(){
对于(int i=0;i<\u options.length;i++){
Log.i(“我”,“选择的选项[i]+”:“+”选择[i]);
}
}
}

如何在此对话框的每一行中添加edittext…请告诉我问题的正确解决方案…

您需要以编程方式创建视图,如下面的链接所示

但是,除了在活动上设置视图,您将把该值传递给对话框上的公共方法“setview”