【发布时间】:2018-03-25 10:39:37
【问题描述】:
我正在努力解决一个问题!
我创建了一个片段来用文本填充页面,所以这里是完整的 OnCreateView:
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.Inflate(Resource.Layout.ProductInfo, container, false);
List<products> SelectedCoinList = (from productname in coinList
where productname.ProductName.Contains(SelectedProductName, StringComparison.OrdinalIgnoreCase)
select productname).ToList<products>();
ImageView ProductLogo = view.FindViewById<ImageView>(Resource.Id.ProductInfoLogo);
var imageBitmap = GetImageBitmapFromUrl("http://******/thumbnails/" + SelectedProductList[position].Symbol + ".png");
ProductLogo.SetImageBitmap(imageBitmap);
TextView txtProductInfoName = view.FindViewById<TextView>(Resource.Id.txtProductInfoName);
txtProductInfoName.Text = SelectedProductList[position].FullName;
TextView txtProductInfoPrice = view.FindViewById<TextView>(Resource.Id.txtProductInfoPrice);
txtProductInfoPrice.Text = "€ " + SelectedProductList[position].Price;
return view;
}
在 MainActivity.cs 我有这段代码(应该)启动片段:
public void ListViewProducts_ItemClick(object sender, AdapterView.ItemClickEventArgs e) {
//Give variables the right value to share with other classes
ProductName = productsList[e.Position].ProductNameName;
position = e.Position;
// Set view to Info
SetContentView(Resource.Layout.ProductInfo);
}
public string GetProductName() {
return ProductName; //return your mainActivity list
}
问题是 Fragment 没有启动或其他什么,因为它加载了 ProductInfo 页面,但带有默认文本。我通过在 OnCreateView 中放置断点来解决这个问题,但没有使用它们。
有什么建议吗?
【问题讨论】:
标签: c# visual-studio xamarin android-activity fragment