如何从课堂上获取细节



我有一个方法,可以将用户插入特定单词的所有电影都返回给我。现在我想将所有细节复制到一个列表中,这样,当用户点击应用程序显示的电影时,它会显示一个带有相应ID的吐司。

How can i do this?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
namespace App_wrapper
{
public class Result1
{
public int vote_count { get; set; }
public int id { get; set; }
public bool video { get; set; }
public double vote_average { get; set; }
public string title { get; set; }
public double popularity { get; set; }
public string poster_path { get; set; }
public string original_language { get; set; }
public string original_title { get; set; }
public List<int> genre_ids { get; set; }
public string backdrop_path { get; set; }
public bool adult { get; set; }
public string overview { get; set; }
public string release_date { get; set; }
}
public class RootObject
{
public int page { get; set; }
public int total_results { get; set; }
public int total_pages { get; set; }
public List<Result1> results { get; set; }
}
}

试试这个

Public List<Film> filmList;
public class Film
{
private String title;
private String id;
public Film(String title, String id)
{
this.title = title;
this.id = id;
}
public String getId()
{
return id;
}
public override string ToString()
{
return title;
}
}

foreach (var paolo in toor.results)
{
var fItem=new Film{title=paolo.title,id=paolo.id}
filmList.Add(fItem);
}

RunOnUiThread(() =>
{
adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, filmList);
lv.Adapter = adapter;
});

//inside ListView_ItemClick
var id_film = filmList.ElementAt(e.Position).id;

供参考如何在自定义对象的android中使用ArrayAdapter

最新更新