I see, my code post got list somehow, I've tried to simplify it a bit, here
it is:

Still trying to figure out why the text edits won't update...

  private class BarAdapter extends BaseAdapter {

    ArrayList<EditText> globalNotesList = new ArrayList<EditText>();

    @Override
    public int getCount() {

      return Globals.bar.items.size();

    }

    @Override
    public long getItemId(int position) {

      return position;

    }

    @Override
    public BarItem getItem(int position) {

      return Globals.bar.items.get(position);

    }


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

      View row = convertView;

      if (row == null) {

        LayoutInflater inflater = getLayoutInflater();

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

      }

      EditText fooNoteEditText = (EditText) row.findViewById(R.id.fooNote);

      BarItem barItem = getItem(position);

      fooNoteEditText.setText(barItem.group.fooNote);

      fooNoteEditText.addTextChangedListener(new
FooNoteTextWatcher(position));

      fooNotesList.add(position, fooNoteEditText);

      return row;

    }

  }

  static boolean lock = false;

  class FooNoteTextWatcher implements TextWatcher {


    FooNoteTextWatcher(int position) {

      this.position = position;

    }

    @Override
    public void afterTextChanged(Editable s) {

      if (lock)
        return;

      Globals.bar.items.get(position).group.fooNote = s.toString();

      // ((BarAdapter) listView.getAdapter()).notifyDataSetChanged();

      String groupName = Globals.bar.items.get(position).group.name;

      for (int i = 0; i < Globals.bar.items.size(); i++)

        if (i != this.position) {

          BarItem barItem = Globals.bar.items.get(i);

          if (barItem.group.name.compareTo(groupName) == 0) {

            lock = true;

            // barItem.group.fooNote = s.toString();

            try {

              EditText fooNoteEditText = ((BarAdapter)
listView.getAdapter()).fooNotesList.get(i);

              if (fooNoteEditText == null) {

                System.out.println("error");

              } else {

                System.out.println("no error");

              }

              if (fooNoteEditText != null) {

                // WE GET HERE, WHY IS SetText NOT SETTING THE TEXT???

                fooNoteEditText.setText(s.toString());
                fooNoteEditText.postInvalidate();
                System.out.println("Success!!!");
                System.out.println(i);
                System.out.println(s.toString());

              }

            } catch (Exception e) {
              System.out.println(e);
            }

            lock = false;

          }

        }

    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int
after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int
count) {

    }

    private int position;

  }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to