엔티티 목록에 따라 dinamically LinearLayouts를 만들어야합니다. 레이아웃은 문제없이 그려집니다. 내 문제는 언제 내가 마지막 레이아웃을 참조했는지 알기 위해 레이아웃을 클릭 한 것입니다. 내가 어떤 도움을 주셔서 감사합니다동적으로 클릭 가능한 선형 레이아웃 만들기
LinearLayout llProducts = FindViewById<LinearLayout>(Resource.Id.llProducts);
LinearLayout llNewProduct;
int i = 0;
foreach(Product p in productsList)
{
llNewProduct = new LinearLayout(this);
llNewProduct.Clickable = true;
llNewProduct.Id = i++;
TextView txtProduct = new TextView(this);
txtProduct.Text = p.Name;
llNewProduct.AddView(txtProduct);
llProducts.AddView(llNewProduct);
llNewProduct.Click += (sender, e)
{
//This always shows the last Id
Toast.MakeText(this, llNewProduct.Id.ToString(), ToastLength.Short).Show();
}
}
:
코드는 다음과 같은 것입니다. 감사합니다
여기서 'llNewProduct.Clickable = true;'는 무엇입니까? – waqaslam