0

編集ボタンをクリックすると、すべての itemnames、desc、price がカスタム リストビューで edittext に入ります。edittext に何も入力できません。edittext をクリックすると、アプリケーションが応答しないというエラーが表示されます。

//my code getview method in Base adapter
public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
     final ViewHolder holder;


        if (convertView == null) {
            holder = new ViewHolder();

            convertView = inflater.inflate(R.layout.editappetisesrlistview, null);
            holder.caption = (EditText) convertView
                    .findViewById(R.id.editappetisertext);
            holder.price=(EditText)convertView.findViewById(R.id.editappetiserprice);
            holder.desc=(EditText)convertView.findViewById(R.id.editappetiserdesc);
            holder.caption1=(ImageView) convertView.findViewById(R.id.editappetiserimage);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        //Fill EditText with the value you have in data source

        holder.caption.setText(itemnames[position]);
        holder.price.setText(prices[position]);
        holder.desc.setText(descs[position]);
        holder.caption.setId(position);
        holder.price.setId(position);
        holder.desc.setId(position);
        holder.caption.setFocusableInTouchMode(true);
        holder.price.setFocusableInTouchMode(true);
        holder.desc.setFocusableInTouchMode(true);

        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;
                    Caption.setFocusable(true);

                  holder.caption.setFocusable(true);
                  arr.remove(holder.caption.getId());
                    arr.add(holder.caption.getId(),holder.caption.getText().toString());


            }
                }

        });    
        holder.price.setOnFocusChangeListener(new OnFocusChangeListener() {
            public void onFocusChange(View v, boolean hasFocus) {
            if(!hasFocus)
            {
                    final int position = v.getId();      
                    final EditText Caption1 = (EditText) v;
                 //   Caption1.setFocusable(true);

                    holder.price.setFocusable(true);
                    arr.remove(holder.price.getId());
                    arr.add(holder.price.getId(),holder.price.getText().toString());


            }
            holder.desc.setOnFocusChangeListener(new OnFocusChangeListener() {
                public void onFocusChange(View v, boolean hasFocus) {
                if(!hasFocus)
                {
                        final int position = v.getId();      
                        final EditText Caption2 = (EditText) v;
                     //   Caption2.setFocusable(true);

                        holder.desc.setFocusable(true);
                        arr.remove(holder.desc.getId());
                        arr.add(holder.desc.getId(),holder.desc.getText().toString());


                }
                    }

            });  

                }

        });  




        return convertView;
    }
}

ビューホルダー.java

class ViewHolder {
    EditText caption,price,desc;
    ImageView caption1;
}

class ListItem {
    String caption;
}

助けてください

4

1 に答える 1

0
mViewHolder.editText = (EditText)convertView.findViewById(R.id.editText1);
            mViewHolder.editText.setTag(position);
            mViewHolder.editText.setTextColor(0xFF000000);
            mViewHolder.editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
                public void onFocusChange(View v, boolean hasFocus) {
                    if (!hasFocus) {
                        EditText et =(EditText)v.findViewById(R.id.editText1);
                        editTextArrayList.set(position,et.getText().toString().trim());
                    }
                }
            });

こんにちは、以下のリンクがあなたに役立つかもしれませんhttp://mylearnandroid.blogspot.in/2014/06/listview-problem-while-scrolling.html

于 2014-06-23T14:36:38.750 に答える