每行的Android ListView setId

时间:2015-04-18 16:57:12

标签: android listview adapter

使用自定义适配器时,如何为ListView中的每一行设置id?

TFragment:

public static TArrayAdapter adapter;
adapter = new TArrayAdapter(getActivity(), R.layout.t_list_item_adapter, new ArrayList<TString>());
    listview.setAdapter(adapter);

TArrayAdapter:

public View getView(final int position, View convertView, final ViewGroup parent) {

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    rowView = inflater.inflate(R.layout.t_list_item_adapter, parent, false);

    THolder holder = new TransactionHolder();
    holder.account = items.get(position);
    holder.name = (TextView) rowView.findViewById(R.id.tvName);
    rowView.setTag(holder);
    setupItem(holder);

0 个答案:

没有答案