Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.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
C# 如何处理RadioGroup.SetOnCheckedChangeListener? 公共类OnAdicionEventArgs:EventArgs { 私有字符串mNome; 私有字符串mPreco; 私人字符串mUnidade; 私有字符串mCategoria; 公共字符串名称 { 获取{return mNome;} 设置{mNome=value;} } 公共字符串预编码 { 获取{return mPreco;} 设置{mPreco=value;} } 公共字符串Unidade { 获取{return mUnidade;} 设置{mUnidade=value;} } 公共字符串分类 { 获取{return mCategoria;} 设置{mCategoria=value;} } public onadictionareventargs(字符串nome、字符串preco、字符串unidade、字符串categoria):base() { Nome=Nome; Preco=Preco; Unidade=Unidade; Categoria=Categoria; } } 类dialog\u Adicionar\u produto:DialogFragment { 双pr=1; 私人按钮mBtnAdicionar; 私有编辑组; 私人编辑部; 私人编辑; 专用单选按钮mRdbUnidades; 私人无线按钮mRdbKilos; 私人放射组; int aux; 公共事件事件处理程序已完成; 创建视图上的公共覆盖视图(布局、充气机、视图组容器、捆绑包保存状态) { base.OnCreateView(充气机、容器、保存状态); var视图=充气机.充气(Resource.Layout.dialog\u adicionar\u produtos,container,false); mBtnAdicionar=view.FindViewById(Resource.Id.btnDialogAdicionar); mNome=view.findviewbyd(Resource.Id.txtNome); mPreco=view.findviewbyd(Resource.Id.txtPreco); mCategoria=view.findviewbyd(Resource.Id.txtCategoria); mRdbUnidades=view.findviewbyd(Resource.Id.rdbUnidades); mRdbKilos=view.findviewbyd(Resource.Id.rdbUnidades); radG=view.findviewbyd(Resource.Id.radioGroup); mBtnAdicionar.Click+=mBtnAdicionar\u Click; mNome.TextChanged+=mNome_TextChanged; mPreco.TextChanged+=mPreco\u TextChanged; mCategoria.TextChanged+=mCategoria_TextChanged; 返回视图; } void mRdbUnidades\u单击(对象发送方,事件参数e) { aux=0; Console.WriteLine(mRdbUnidades.Text); } void mRdbKilos\u单击(对象发送方,事件参数e) { aux=1; Console.WriteLine(mRdbKilos.Text); } void mBtnAdicionar_单击(对象发送者,事件参数e) { //用户已单击“注册”按钮 如果(aux==0){ 调用(这是一个新的OnadicionEventArgs(mNome.Text、mPreco.Text、mRdbKilos.Text、mCategoria.Text)); 这个。解散(); }否则{ 调用(这是一个新的OnadicionEventArgs(mNome.Text、mPreco.Text、mRdbUnidades.Text、mCategoria.Text)); 这个。解散(); } } }_C#_Android_Xamarin_Radio Button - Fatal编程技术网

C# 如何处理RadioGroup.SetOnCheckedChangeListener? 公共类OnAdicionEventArgs:EventArgs { 私有字符串mNome; 私有字符串mPreco; 私人字符串mUnidade; 私有字符串mCategoria; 公共字符串名称 { 获取{return mNome;} 设置{mNome=value;} } 公共字符串预编码 { 获取{return mPreco;} 设置{mPreco=value;} } 公共字符串Unidade { 获取{return mUnidade;} 设置{mUnidade=value;} } 公共字符串分类 { 获取{return mCategoria;} 设置{mCategoria=value;} } public onadictionareventargs(字符串nome、字符串preco、字符串unidade、字符串categoria):base() { Nome=Nome; Preco=Preco; Unidade=Unidade; Categoria=Categoria; } } 类dialog\u Adicionar\u produto:DialogFragment { 双pr=1; 私人按钮mBtnAdicionar; 私有编辑组; 私人编辑部; 私人编辑; 专用单选按钮mRdbUnidades; 私人无线按钮mRdbKilos; 私人放射组; int aux; 公共事件事件处理程序已完成; 创建视图上的公共覆盖视图(布局、充气机、视图组容器、捆绑包保存状态) { base.OnCreateView(充气机、容器、保存状态); var视图=充气机.充气(Resource.Layout.dialog\u adicionar\u produtos,container,false); mBtnAdicionar=view.FindViewById(Resource.Id.btnDialogAdicionar); mNome=view.findviewbyd(Resource.Id.txtNome); mPreco=view.findviewbyd(Resource.Id.txtPreco); mCategoria=view.findviewbyd(Resource.Id.txtCategoria); mRdbUnidades=view.findviewbyd(Resource.Id.rdbUnidades); mRdbKilos=view.findviewbyd(Resource.Id.rdbUnidades); radG=view.findviewbyd(Resource.Id.radioGroup); mBtnAdicionar.Click+=mBtnAdicionar\u Click; mNome.TextChanged+=mNome_TextChanged; mPreco.TextChanged+=mPreco\u TextChanged; mCategoria.TextChanged+=mCategoria_TextChanged; 返回视图; } void mRdbUnidades\u单击(对象发送方,事件参数e) { aux=0; Console.WriteLine(mRdbUnidades.Text); } void mRdbKilos\u单击(对象发送方,事件参数e) { aux=1; Console.WriteLine(mRdbKilos.Text); } void mBtnAdicionar_单击(对象发送者,事件参数e) { //用户已单击“注册”按钮 如果(aux==0){ 调用(这是一个新的OnadicionEventArgs(mNome.Text、mPreco.Text、mRdbKilos.Text、mCategoria.Text)); 这个。解散(); }否则{ 调用(这是一个新的OnadicionEventArgs(mNome.Text、mPreco.Text、mRdbUnidades.Text、mCategoria.Text)); 这个。解散(); } } }

C# 如何处理RadioGroup.SetOnCheckedChangeListener? 公共类OnAdicionEventArgs:EventArgs { 私有字符串mNome; 私有字符串mPreco; 私人字符串mUnidade; 私有字符串mCategoria; 公共字符串名称 { 获取{return mNome;} 设置{mNome=value;} } 公共字符串预编码 { 获取{return mPreco;} 设置{mPreco=value;} } 公共字符串Unidade { 获取{return mUnidade;} 设置{mUnidade=value;} } 公共字符串分类 { 获取{return mCategoria;} 设置{mCategoria=value;} } public onadictionareventargs(字符串nome、字符串preco、字符串unidade、字符串categoria):base() { Nome=Nome; Preco=Preco; Unidade=Unidade; Categoria=Categoria; } } 类dialog\u Adicionar\u produto:DialogFragment { 双pr=1; 私人按钮mBtnAdicionar; 私有编辑组; 私人编辑部; 私人编辑; 专用单选按钮mRdbUnidades; 私人无线按钮mRdbKilos; 私人放射组; int aux; 公共事件事件处理程序已完成; 创建视图上的公共覆盖视图(布局、充气机、视图组容器、捆绑包保存状态) { base.OnCreateView(充气机、容器、保存状态); var视图=充气机.充气(Resource.Layout.dialog\u adicionar\u produtos,container,false); mBtnAdicionar=view.FindViewById(Resource.Id.btnDialogAdicionar); mNome=view.findviewbyd(Resource.Id.txtNome); mPreco=view.findviewbyd(Resource.Id.txtPreco); mCategoria=view.findviewbyd(Resource.Id.txtCategoria); mRdbUnidades=view.findviewbyd(Resource.Id.rdbUnidades); mRdbKilos=view.findviewbyd(Resource.Id.rdbUnidades); radG=view.findviewbyd(Resource.Id.radioGroup); mBtnAdicionar.Click+=mBtnAdicionar\u Click; mNome.TextChanged+=mNome_TextChanged; mPreco.TextChanged+=mPreco\u TextChanged; mCategoria.TextChanged+=mCategoria_TextChanged; 返回视图; } void mRdbUnidades\u单击(对象发送方,事件参数e) { aux=0; Console.WriteLine(mRdbUnidades.Text); } void mRdbKilos\u单击(对象发送方,事件参数e) { aux=1; Console.WriteLine(mRdbKilos.Text); } void mBtnAdicionar_单击(对象发送者,事件参数e) { //用户已单击“注册”按钮 如果(aux==0){ 调用(这是一个新的OnadicionEventArgs(mNome.Text、mPreco.Text、mRdbKilos.Text、mCategoria.Text)); 这个。解散(); }否则{ 调用(这是一个新的OnadicionEventArgs(mNome.Text、mPreco.Text、mRdbUnidades.Text、mCategoria.Text)); 这个。解散(); } } },c#,android,xamarin,radio-button,C#,Android,Xamarin,Radio Button,我想在用户选中一个或另一个单选按钮时,获取当前选中单选按钮的值。但是我怎么能做到呢?不使用RadioButton。单击鼠标右键? 我将通过RadioButton.Text获取该值,它将从选中的按钮获取该值。改用CheckedChange事件,您将收到所选RadioButton的id: public class OnAdicionarEventArgs : EventArgs { private string mNome; p

我想在用户选中一个或另一个单选按钮时,获取当前选中单选按钮的值。但是我怎么能做到呢?不使用RadioButton。单击鼠标右键?
我将通过RadioButton.Text获取该值,它将从选中的按钮获取该值。

改用CheckedChange事件,您将收到所选RadioButton的id:

    public class OnAdicionarEventArgs : EventArgs
        {
            private string mNome;
            private string mPreco; 
            private string mUnidade;
            private string mCategoria;

            public string Nome
            {
                get{ return mNome; }
                set{ mNome=value;}

            }
            public string Preco
            {
                get{ return mPreco; }
                set{ mPreco=value;}

            }
            public string Unidade
            {
                get{ return mUnidade; }
                set{ mUnidade=value;}

            }
            public string Categoria
            {
                get{ return mCategoria; }
                set{ mCategoria=value;}

            }

            public OnAdicionarEventArgs (string nome, string preco, string unidade, string categoria) : base()
            {
                Nome = nome;
                Preco = preco;
                Unidade = unidade;
                Categoria = categoria;
            }

        }

        class dialog_Adicionar_produto:DialogFragment
        {
            double pr=1;
            private Button mBtnAdicionar;
            private EditText mNome;
            private EditText mPreco;

            private EditText mCategoria;
            private RadioButton mRdbUnidades;
            private RadioButton mRdbKilos;
            private RadioGroup radG;
            int aux;

            public event EventHandler<OnAdicionarEventArgs> mOnAdicionarComplete;


            public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
            {
                base.OnCreateView (inflater, container, savedInstanceState);

                var view = inflater.Inflate (Resource.Layout.dialog_adicionar_produtos, container, false);

                mBtnAdicionar = view.FindViewById<Button> (Resource.Id.btnDialogAdicionar);
                mNome = view.FindViewById<EditText> (Resource.Id.txtNome);
                mPreco = view.FindViewById<EditText> (Resource.Id.txtPreco);

                mCategoria = view.FindViewById<EditText> (Resource.Id.txtCategoria);

                mRdbUnidades = view.FindViewById<RadioButton> (Resource.Id.rdbUnidades);
                mRdbKilos = view.FindViewById<RadioButton> (Resource.Id.rdbUnidades);

                radG = view.FindViewById<RadioGroup> (Resource.Id.radioGroup);

                mBtnAdicionar.Click += mBtnAdicionar_Click;
                mNome.TextChanged += mNome_TextChanged;
                mPreco.TextChanged += mPreco_TextChanged;

                mCategoria.TextChanged += mCategoria_TextChanged;





                return view;
            }

            void  mRdbUnidades_Click(object sender, EventArgs e)
            {

                aux = 0;
                Console.WriteLine (mRdbUnidades.Text);
            }

            void mRdbKilos_Click (object sender, EventArgs e)
            {

                aux = 1;
                Console.WriteLine (mRdbKilos.Text);
            }

            void mBtnAdicionar_Click (object sender, EventArgs e)
            {

                //User has clicked the sign up button
                if (aux == 0) {
                    mOnAdicionarComplete.Invoke (this, new OnAdicionarEventArgs (mNome.Text, mPreco.Text, mRdbKilos.Text, mCategoria.Text));
                    this.Dismiss ();
                } else {
                    mOnAdicionarComplete.Invoke (this, new OnAdicionarEventArgs (mNome.Text, mPreco.Text, mRdbUnidades.Text, mCategoria.Text));
                    this.Dismiss ();
                }

            }
}
radG.CheckedChange+=(发送方,e)=>{
Console.WriteLine(view.findviewbyd(e.CheckedId.Text);
}
radG.CheckedChange += (sender, e) => {
    Console.WriteLine(view.FindViewById<RadioButton>(e.CheckedId).Text);
}