我写了一个listview 包含多个显示图片的item,我如何才能只改变其中某item的一个图片其他的不变,假设我知道该item的id。。PS:并不是点击该item才改变,而是通过我的程序其他部分产生的一个值来判断是否要改变的

解决方案 »

  1.   

    假如 你点击以后 会获取到一个位置信息 ,然后通过listview 获取到那个 item 的layout 然后获取那个控件 然后改变信息 就OK了
      

  2.   

    listview 如何通过ID获取ltem的layout呢
      

  3.   

    public abstract void onItemClick (AdapterView<?> parent, View view, int position, long id)Added in API level 1
    Callback method to be invoked when an item in this AdapterView has been clicked.Implementers can call getItemAtPosition(position) if they need to access the data associated with the selected item.Parameters
    parent The AdapterView where the click happened.
    view The view within the AdapterView that was clicked (this will be a view provided by the adapter)
    position The position of the view in the adapter.
    id The row id of the item that was clicked.这里面的这个View 就是你需要的那个layout   layout.findViewById  我就不用多说了吧
      

  4.   

    ListView.getItemAtPosition(position);
    public Object getItemAtPosition (int position)Added in API level 1
    Gets the data associated with the specified position in the list.Parameters
    position Which data to get
    Returns
    The data associated with the specified position in the list忽略上面两个 对于错误答案请您见谅
      

  5.   

    对于这个函数的返回值我应该用什么对象获得值呢你的item 的对应layout
      

  6.   

    对于这个函数的返回值我应该用什么对象获得值呢你的item 的对应layout
    可以具体点么。比如我的item对应的配置文件为A.XML,然后我想改变其中的ImageView
      

  7.   

    你的A.xml  这里获得的object  应该就是 这个 a.xml最外层的ViewGroup
      

  8.   

    好了解决了 用一个View对象接受就好了。谢谢了
      

  9.   

      在吗楼主,可以把这份代码给我看看嘛,[email protected],感激不尽