2012-04-09 3 views
0

저는 서버 데이터베이스에서 모든 menunames를 URL을 통해 가져 오는 중이며 기본 어댑터를 사용하여 editext 사용자 정의 listview에 모든 menunames를 추가합니다. 이제 Edittext가 목록 배열로 값을 변경했습니다. 내가 menntames 또는 not.Eg:x,yz를 변경하는지 여부를 저장하는 edittext 모든 값을 원합니다. 데이터베이스에서 오는 menunames가 editext에 추가됩니다. 이제 menuname y가 b로 변경됩니다. 내가 원하는 editext.now에서 C의 Z [, bc를 X를 ..]의 ArrayList에 vaules하지만 지금 내가 editext 값 변경 여부 또는 전부의 EditText 값을 원하는안드로이드의 기본 어댑터를 사용하여 사용자 정의 된 목록보기의 배열 목록에있는 모든 텍스트 값을 가져 오는 방법

  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; 
    } 

C를 B를 얻고있다. purpous 업데이트. 나는 모든 menunames를 이전에 얻을 수있다. 당신이 원하는 경우

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(); 
    } 
}); 

지금 글고에서 데이터를 얻을 onTextChanged, beforeTextChanged 또는 afterTextChanged을 : 나는 getView()

코드에 EditTextTextChangedListener 추가 새로운 menunames

+0

혼란스러워 ... 문제가 정확히 무엇입니까? –

+0

예 : 내 editext에 x, y, z가 있습니다. 나는 editext에서 b로 값 y를 바꿨다. 지금 arraylist.now ur에서 z, b, z를 얻고 싶다. 내 문제를 이해했다. – Vinoth

답변

1

에 오래된 menunames를 업데이트합니다.

+0

위의 메서드를 사용한다. 내가 변경된 text.EG:xyz menunames가 오기 전에 얻는다. 데이터베이스를 edittext.now에 추가 menase menase를 변경할 수 없습니다. 배열 목록에서 x, y, z를 원합니다. 내가 edittext를 변경하면 b 메 나스로 x, bz를 얻으려고합니다. – Vinoth

+0

public void onTextChanged (CharSequence s, int start, int before, int count) { 문자열 데이터 = s입니다. toString() } – user370305

관련 문제