2012-04-05 12 views
1

データベースから項目名を取り出して編集テキストに追加することができます。変更された値を編集テキストに保存するにはどうすればよいですか?私はそれらを文字列配列に格納します。アンドロイドでリストビューをカスタマイズする際に、文字列配列のedittextchanged値を取得する方法

  public class EditMainMenulistview extends BaseAdapter { 
protected static Context Context = null; 
int i; 
public String editnewmainmenu, menuname,edittext; 
String qrimage; 
Bitmap bmp, resizedbitmap; 
Bitmap[] bmps; 
Activity activity = null; 
private LayoutInflater inflater; 

private ImageView[] mImages; 
String[] itemimage; 
TextView[] tv; 
String itemname, itemcode; 
public String[] itemnames, itemcodes; 
HashMap<String, String> map = new HashMap<String, String>(); 

public EditMainMenulistview(Context context, JSONArray imageArrayJson) { 
    Context = context; 
    // inflater = 
    // (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    // imageLoader=new ImageLoader(activity); 
    inflater = LayoutInflater.from(context); 
    this.mImages = new ImageView[imageArrayJson.length()]; 
    this.bmps = new Bitmap[imageArrayJson.length()]; 
    this.itemnames = new String[imageArrayJson.length()]; 
    this.itemcodes = new String[imageArrayJson.length()]; 

    try { 

     for (i = 0; i < imageArrayJson.length(); i++) { 
      JSONObject image = imageArrayJson.getJSONObject(i); 
      qrimage = image.getString("menuimage"); 
      itemname = image.getString("menuname"); 
      itemcode = image.getString("menucode"); 
      itemnames[i] = itemname; 
      itemcodes[i] = itemcode; 

      byte[] qrimageBytes = Base64.decode(qrimage.getBytes()); 

      bmp = BitmapFactory.decodeByteArray(qrimageBytes, 0, 
        qrimageBytes.length); 
      int width = 100; 
      int height = 100; 
      resizedbitmap = Bitmap.createScaledBitmap(bmp, width, height, 
        true); 
      bmps[i] = bmp; 

      mImages[i] = new ImageView(context); 
      mImages[i].setImageBitmap(resizedbitmap); 

      mImages[i].setScaleType(ImageView.ScaleType.FIT_START); 

      // tv[i].setText(itemname); 
     } 
     System.out.println(itemnames[i]); 


    } catch (Exception e) { 
     // TODO: handle exception 
    } 
} 

public int getCount() { 
    return mImages.length; 
} 

public Object getItem(int position) { 
    return position; 
} 

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

public View getView(final int position, View convertView, ViewGroup parent) { 
    final HashMap<String, String> map=new HashMap<String, String>(); 
    View vi = convertView; 

    vi = inflater.inflate(R.layout.editmainmenulist, null); 

    EditText text = (EditText) vi.findViewById(R.id.editmaimenu); 
    ImageView image = (ImageView) vi.findViewById(R.id.menuimage); 


    image.setImageBitmap(bmps[position]); 
    text.append(itemnames[position]); 
    String edittext=text.toString(); 
    text.addTextChangedListener(new TextWatcher() {    
     public void onTextChanged(CharSequence s, int start, int before, int count) { 

     } 

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

     } 

     public void afterTextChanged(Editable s) { 
      if(text.length() > 0) { 
       String newName = text.getText().toString(); 
      } else if(text.length() == 0) { 

      } 
     } 
     });    
    //Toast.makeText(Context, edittext, Toast.LENGTH_LONG).show(); 
    return vi; 
} 

}

私は、Android携帯での私のMySQLデータベースからすべての項目名を取り、editextにそれらを追加します。管理者は項目名(複数)を変更することができ、変更された場合、前の項目名を置き換えます。私はそれらを更新したい。あなたは、データベースを更新し、このイベントの後にDIS

myEditText.addTextChangedListener(new TextWatcher() {    
     @Override 
     public void onTextChanged(CharSequence s, int start, int before, int count) { 

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

     } 
     @Override 
     public void afterTextChanged(Editable s) { 
      if(myEditText.length() > 0) { 
       String newName = myEditText.getText().toString(); 
      } else if(myEditText.length() == 0) { 

      } 
     } 
     }); 

のようなsomethinをしなければならない

+0

私はuがデータベースに名前を更新したいと思います? –

+0

ya sir ..私は更新をしたいと思います。解決策を教えてください。私は過去の一週間を構造化してください。 – Vinoth

+0

OKあなたはその行の一意のIDを読み、名前を編集した後、その行の一意のIDを読み取ってデータベースの更新クエリを実行します。 –

答えて

0

...

+0

islEdtTxtSrchこれは何ですか – Vinoth

+0

私のコードを一度ご覧ください。私は私の完全なコードを更新することができます..今私に教えてくださいを参照してください – Vinoth

+0

私はURコードにURコードを編集したので、URシステムでこの画面をリフレッシュするので、変更 –

関連する問題