0

我有一个带有自定义适配器的自定义列表视图。自定义列表视图由图像和两个文本视图组成,比如 textViewA 和 textViewB。现在我想在自定义列表视图的每一行中更改 textViewB 的文本而不更新其他组件。我的第一个问题可能吗?如果是,那么我该怎么做。

4

3 回答 3

0

您是否尝试过将String[]参数传递给您的适配器?就像是:

public class CustomAdapter extends BaseAdapter {

  String[] data_text;

  CustomAdapter() {

  }

  CustomAdapter(String[] text) {
      data_text = text;
  }

  CustomAdapter(ArrayList<String> text) {

      data_text = new String[text.size()];

  for (int i = 0; i < text.size(); i++) {
      data_text[i] = text.get(i);
   }

  }

  @Override
    public int getCount() {
      return data_text.length;
  }

  @Override
    public String getItem(int position) {
      return null;
  }

  @Override
    public long getItemId(int position) {
      return position;
  }

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

      LayoutInflater inflater = getLayoutInflater();
      View row;

      row = inflater.inflate(R.layout.drawer_list_item, parent, false);

      TextView textview = (TextView) row.findViewById(R.id.text1);

      textview.setText(data_text[position]);

   return (row);

  }

}
于 2013-08-01T23:49:42.250 回答
0

您必须调用 notifyDataSetChanged() 并更改适配器中 textview 的值。

于 2013-08-02T02:41:27.407 回答
0
listView.setadaptor(null);
// do what ever methods here to change your data, strings objects, etc
listview.notifyDataSetChanged();
于 2013-08-02T03:54:16.743 回答