小编Ric*_*ard的帖子

将参数传递给listview行中按钮上的onclick侦听器

我刚开始使用android而且遇到了一些问题.
我创建了一个ListView从数据库填充的.
每行都有一个按钮,用于从列表和数据库中删除项目.

我能够将事件监听器连接到按钮,但我无法确定要删除的匹配数据库记录.

我的班级如下所示

public class FeedArrayAdapter extends ArrayAdapter<Feed> implements OnClickListener
{
    private ARssEReaderDBAdapter dba;
    private String TAG = "FeedArrayAdapter";

    public FeedArrayAdapter(Context context, int textViewResourceId, List<Feed> items)          {
    super(context, textViewResourceId, items);
    Log.w(TAG, "List");


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Log.w(TAG, "getView");
        View v = convertView;
        if (v == null) {
            LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.feedlistrow, null);
    }
    Feed feed = getItem(position);
    if (feed != null) {
        TextView title = (TextView)v.findViewById(R.id.TextView01);
        if …
Run Code Online (Sandbox Code Playgroud)

android listview button

20
推荐指数
2
解决办法
3万
查看次数

标签 统计

android ×1

button ×1

listview ×1