我想在android应用kotlin的listview中添加文本和图像。我已经成功解析了listview中的文本,但是无法添加图像。我也正在获取图像的url,例如url / image.jpeg,但是不知道如何在override fun getView
的imageview中添加图像。
代码:
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
val view : View = LayoutInflater.from(context).inflate(R.layout.row_layout,parent,false)
val CallsingID = view.findViewById(R.id.callsign_id) as AppCompatTextView
val StatusID = view.findViewById(R.id.airline_id) as AppCompatTextView
val LogoAriline = view.findViewById(R.id.imageView) as ImageView
// l have to add image here to get result
CallsingID.text = list[position].Callsign.toString()
StatusID.text = list[position].Airline
return view
}
答案 0 :(得分:1)
var o = p.GetValue(this,null);
EventInfo eventInfo = t.GetEvent("CollectionChanged", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
var handler = new Action<object, NotifyCollectionChangedEventArgs>((s, a) => { Console.WriteLine("Changed + " + this.TestInt.ToString()); });
Delegate del = Delegate.CreateDelegate(eventInfo.EventHandlerType, handler.Target, handler.Method);
eventInfo.AddEventHandler(o, del);
或另外实现Picasso http://square.github.io/picasso/
并使用:
LogoAriline.setImageResource(R.drawable.drawableName)
答案 1 :(得分:1)
您可以使用Glide库
<sys/auxv_386.h>
答案 2 :(得分:0)
Picasso.get().load(list[position].logo).into(LogoAriline)