本文介绍了CLOSED:如何从列表视图获取值值项的onclick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关闭,对不起,暂FIX。

CLOSED, SORRY HAVE FIX.


我有成功使该带底座适配器扩展自定义适配器,我把从DATAS到sqlite的列表视图。我想从列表视图数据进行该产品我点击。如何获得价值/对象并将其存储到变量字符串。实施例I在ItemsArtikel.class的setName已设置。我想的GetName。从列表视图,我点击它。

I have success make custom adapter which extends with base adapter and I put datas from sqlite to listview. I want to get data from listview which the item I click. How to get value/object and store it to variable String. Example I have set in ItemsArtikel.class setName. And I want to getName. from listview which I click it.

我的code:

rowItems = (List<ItemsArtikel>) db.getAllKategori(katname);

kategoriListView.setAdapter(new CustomBaseAdapter(this, rowItems));
kategoriListView.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view,
            int position, long id) {

        String a = // what code to get name value;
        Log.d("MyLog", "" + a);
    }
});

对不起我的英文不好。

Sorry My bad english.

感谢。

只需code如下:

rowItems = (List<ItemsArtikel>) db.getAllKategori(katname);

kategoriListView.setAdapter(new CustomBaseAdapter(this, rowItems));
kategoriListView.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view,
            int position, long id) {

        String a = rowItems.get(position).getName();
        Log.d("MyLog", "" + a);
    }
});

和然后我得到的值名称。对不起。

And then I get value name. Sorry.

推荐答案

您必须实现在适配器的方法。
如果适配器一个项目是1:1匹配列表视图,可以修改CustomBaseAdapter的getItem方法。或者,你可以创建一个新的方法来获得对应的位置值

You have to implement a method in the adapter.If an item in adapter is 1:1 matched with listview, you can modify getItem method in CustomBaseAdapter. Or, you could create a new method to get the value corresponding to its position

这篇关于CLOSED:如何从列表视图获取值值项的onclick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 00:35