android - 图标加载不出来

标签 android xamarin navigation

您好,我的图标无法加载,我不知道为什么。它们应该出现在导航中。我很新,找不到好的新资源来学习。 一切都是旧的。一些链接会有所帮助谢谢你。

enter image description here

enter image description here

enter image description here

最佳答案

GetView 需要在布局中的ImageButton 上设置图像。请注意,您甚至没有在适配器中使用 items?而不是使用 ImageButton 列表,为什么不接受可绘制对象,然后从项目中设置每个 ImageButton 的图像?查看 GetView 的更新版本(下方),它应该为您提供一个在每个按钮的 ImageButton 上设置图像的工作示例。

public override View GetView(int position, View convertView, ViewGroup parent) {
     View v = convertView;
     if(v == null){
         v = LayoutInflater.From(context).Inflate(Resource.Layout.MenuButtonLayout, parent, false);
     }
     var imageButton = v.FindViewById<ImageButton>(Resource.Id.myButton); 
     imageButton.SetImageResource(Resource.Drawable.Noten);
     return v;
 }

关于android - 图标加载不出来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37421409/

相关文章:

android - ScrollView 内的 FlowLayout

android - BottomNavigationView 文本调整大小动画问题基于所使用的主题

html - 下拉列表中的父李在悬停时不改变颜色

android - Unresolved reference : NavArgs after added some arguments to destination

android - 我如何为整个 snackbar 布局设置 Action ,而不仅仅是为文本设置 Action ?

android fragment 方向改变

c# - 在 C#/Xamarin 中等待线程完成

android - 如何让 Holo Light 主题在我的 Xamarin 应用程序中工作

c# - Toast 通知不起作用

xamarin - 在 Xamarin Forms 中推送多个页面