ListView: how to access Item's elements programmatically from outside?

前端 未结 6 960
长情又很酷
长情又很酷 2021-01-22 02:17

I have the following situation.

I have a ListView, each item of the ListView is comprised of different widgets (TextViews, ImageViews, etc...) inflated form a Layout in

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-22 02:27

    try this one:

    View v=lv.getAdapter().getView(index, null, lv);
    View card =(View)v.findViewById(R.id.card);
    card.setBackgroundResource(R.drawable.pressed_background_card);
    card.invalidate();
    v.invalidate();
    

    those function force your views to redraw itself and they will render again. look at invalidate()

提交回复
热议问题