如何将List <class name>转换为String数组。</classname>

时间:2014-05-19 17:35:39

标签: android casting typeconverter

public class Favoriler extends Fragment{
    List<ListViewItem> items;

    FavoriCustomLw adapter;
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){

        View v=inflater.inflate(R.layout.favoriler, null);
        ListView cListView=(ListView)v.findViewById(R.id.customlw);
        items  = new ArrayList<Favoriler.ListViewItem>();
        if(YabanciDiziler.contextlistposition==0){
            items.add(new ListViewItem()
            {{
                ResimKaynak = R.drawable.arrow;
                DiziIsmi = "Arrow";
                ImdbPuan = "Imdb: 9.5";
                Tur="Aksiyon";
            }});
        }


        adapter = new FavoriCustomLw(getActivity(),items);
        cListView.setAdapter(adapter);

        cListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int position,
                long id) {
            // TODO Auto-generated method stub


        }
        });

        return v;


    }

    class ListViewItem
    {
        public int ResimKaynak;
        public String DiziIsmi;
        public String ImdbPuan;
        public String Tur;

    }

}

您好我使用自定义ListView。我想将List<ListViewItem> items= new ArrayList<Favoriler.ListViewItem>();转换为String数组。我想将转换后的字符串添加到ListView的{​​{1}}方法中。 我想做这样的事情:

setOnItemClickListener()

但我无法使用cListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int position, long id) { if(items[position].equals("Arrow")){ } } }); 。我该怎么转换呢?

1 个答案:

答案 0 :(得分:0)

因为这不是你得到它的方式。你这样做

items.get(position).equals("Arrow");