Android에서 버튼 클릭으로 Stacklayout에 라벨보기를 추가하려고했습니다. 하지만 Null 포인터 예외가 발생합니다. 아래는 내가 습득하려는 것입니다. 사람이 ButtonClick에 라벨을 추가버튼에 부모를 추가하십시오. Xamarin.forms를 클릭하십시오.
StackLayout parent= new StackLayout();
Button add= new Button
{
HorizontalOptions=LayoutOptions.End,
BackgroundColor=Xamarin.Forms.Color.White,
Text="ADD",
TextColor=Xamarin.Forms.Color.Maroon,
};
add.Clicked += OnButtonClicked;
Label firstLabel = new Label
{
Text = "Label 1",
HorizontalOptions = LayoutOptions.StartAndExpand,
TextColor=Xamarin.Forms.Color.FromHex("#000000")
};
parent.Children.Add(add);
parent.Children.Add(firstLabel);
void OnButtonClicked(object sender, EventArgs e)
{
Label secondLabel = new Label
{
Text = "Label 1",
HorizontalOptions = LayoutOptions.StartAndExpand,
TextColor=Xamarin.Forms.Color.FromHex("#000000")
};
parent.Children.Add(secondLabel);
}
감사합니다 사전
에서 C#으로Xamarin.Forms 코드 xamarin.forms이를 acheive하는 방법에 대한 조언을 주시겠습니까
: 항상 버전 충돌이 버전은 테스트 및 iOS에서 작동했다
을하지 않는 수행 솔루션 수준에서 패키지를 업데이트합니다. 가져 오는 스택 추적으로 게시물을 편집 할 수 있습니까? –