public override View GetView(int position, View convertView, ViewGroup parent) { View view = convertView; if (view == null) { view = LayoutInflater.From(context).Inflate(Resource.Layout.activity_holder, null); } var NumberContainer = view.FindViewById <TextView>(Resource.Id.NumberContainer); var img_box_state = view.FindViewById <ImageView>(Resource.Id.ImageContainer); var Btn_Container_Fold = view.FindViewById <Button>(Resource.Id.ContainerFold); var Btn_Container_Unfold = view.FindViewById <Button>(Resource.Id.ContainerUnfold); var Btn_Stop = view.FindViewById <Button>(Resource.Id.StopButton); var number = (position + 1).ToString(); NumberContainer.Text = number; string origin_topic = (number == "1") ? topic_1 : topic_2; //сложить Btn_Container_Fold.Click += delegate(object select, EventArgs eventArgs) { img_box_state.SetImageResource(Resource.Drawable.containerFolded); SetBtnBackground(select, eventArgs, "fold", ref Btn_Container_Fold, ref Btn_Container_Unfold); _service.PublishBoxState(origin_topic, "2"); }; //остановка Btn_Stop.Click += delegate(object select, EventArgs eventArgs) { SetBtnBackground(select, eventArgs, "off", ref Btn_Container_Fold, ref Btn_Container_Unfold); _service.PublishBoxState(origin_topic, "0"); }; //разложить Btn_Container_Unfold.Click += delegate(object select, EventArgs eventArgs) { img_box_state.SetImageResource(Resource.Drawable.containerUnfolded); SetBtnBackground(select, eventArgs, "unfold", ref Btn_Container_Fold, ref Btn_Container_Unfold); _service.PublishBoxState(origin_topic, "1"); }; return(view); }
private void BtnSendingCommand(object sender, EventArgs e) { mQTT.PublishBoxState(topic, CommandText.Text); }