错误edittext它不能将特定的东西集中在基本适配器的自定义布局(来自mysql数据库)中

时间:2012-04-06 01:41:08

标签: android web-services

您好先生我从自定义列表视图中的数据库中获取项目名称附加到edittext.after汇编所有附加到edittext的项目名称。

如果我想要更改itemname menas,我会在edittext上抓取它,专注于另一个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<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);

    final EditText text = (EditText) vi.findViewById(R.id.editmaimenu);
    ImageView image = (ImageView) vi.findViewById(R.id.menuimage);
    text.requestFocus();
    image.setImageBitmap(bmps[position]);
    text.append(itemnames[position]);
    String edittext = text.toString();

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

    return vi;

}

请提及以上代码,如果任何人可以重播意味着真的很感激

1 个答案:

答案 0 :(得分:0)

为什么在getview()中使用text.requestFocus()。假设您在listview中可见10个项目,则getview被调用10次。所以text.requestFocus()也被称为10次,因此焦点将放在最后一个可见项