0

I am fetching all menunames from server database through url i append all menunames into editext customized listview using base adapter. now i am getting Edittext changed values into list array .now i want store edittext all values, whether he changes menunames or not.Eg:x,yz... menunames coming from database append to the editext now i am changed menuname y to b and z to c in editext.now i want [x,b.c...] vaules in arraylist but now i am getting b,c

          this is my code
            public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;


    if (convertView == null) {
        holder = new ViewHolder();
        convertView = inflater.inflate(R.layout.editmainmenulist, null);
        holder.caption = (EditText) convertView
                .findViewById(R.id.editmaimenu);
        holder.caption1=(ImageView) convertView.findViewById(R.id.menuimage);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    //Fill EditText with the value you have in data source
    holder.caption.setText(itemnames[position]);//here only i append database menunames
    holder.caption.setId(position);
    holder.caption1.setImageBitmap(bmps[position]);

    //we need to update adapter once we finish with editing
    holder.caption.setOnFocusChangeListener(new OnFocusChangeListener() {
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus){
                final int position = v.getId();
                final EditText Caption = (EditText) v;
                itemnames[position] = Caption.getText().toString();

                arr.add(Caption.getText().toString());//here only i think problem..please see any body can tell what i have mistake has been done


            }
        }    
    });     

    return convertView;
}
      }

           class ViewHolder {
EditText caption;
ImageView caption1;
      }

    class ListItem {
String caption;
     }

i want all edittext values in whether the editext values change or not. for update purpous. i can get all menunames previous . i want update old menunames into new menunames

2
  • Got confused...whats your problem exactly? Commented Apr 9, 2012 at 5:03
  • Eg:in my editext contains x,y,z. i changed value y as b in editext ..now i want get x,b,z in arraylist.now ur understood my problem or not Commented Apr 9, 2012 at 5:06

1 Answer 1

1

Add TextChangedListener to your EditText in getView()

Code:

holder.caption.addTextChangedListener(new TextWatcher()
{           
  @Override
   public void onTextChanged(CharSequence s, int start, int before, int count)
    {
     // TODO Auto-generated method stub         
    }           
    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after)
    {
     // TODO Auto-generated method stub
     }
    @Override
    public void afterTextChanged(Editable s)
    {
    // TODO Auto-generated method stub
    String data =  holder.caption.getText().toString().trim();
    }
});

Now get the data from edittext when you want, onTextChanged, beforeTextChanged or afterTextChanged..

Sign up to request clarification or add additional context in comments.

2 Comments

i use above method..i get after,before changed text.EG:xyz menunames comes from database append to edittext.now i cannot change menunames menase i want get x,y,z in array list. if i change edittext vlaue y to b menas i want get x,b.z in arraylist
Also you can use, @Override public void onTextChanged(CharSequence s, int start, int before, int count) { String data = s.toString() }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.