android定义字符串列表,如何在android中的自定义列表视图中的字符串数组中获取edittext更改的值...

我可以从数据库中获取项目名称并将它们追加到编辑文本中。如何将更改的值存储在编辑文本中?我希望它们存储在一个字符串数组中。

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 map = new HashMap();

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 map=new HashMap();

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。管理员可以更改项目名称(不止一个),并且在更改时,它应该替换以前的项目名称。我想更新它们。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值