Edit text focus misbehaving in Custom Listview
<p>I am have created a Custom list view with edit-text , button to delete that item in list-view and adding items at run time on click of button, For only item it works fine but if a add for items in list then edit-text gives focus problem and i am unable to write anything in any of the edit-text on the other side code is working perfect on emulator. </p>

<p>Here's my code</p>

<p>Activity Class
    public class Activity_Add_CustomArea extends BaseActivity implements View.OnClickListener, AdapterAddCustomArea.DeletePosition {
        ListView ListView_custom;
        List arraylist_addArea;</p>

<pre><code>    private LinearLayout relativeLayout_textViewArea, linear_listview;
    AdapterAddCustomArea adapterAddCustomArea;
    private TextView txt_header;
    private Button customArea_back_btn;
    int i = 1;
    public static int starRating = 0;
    public static int starRatingPosition = 0;
    public static String ROOM_IMAGE = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_custom_area);
        relativeLayout_textViewArea = (LinearLayout) findViewById(R.id.Relatve_txtview);
        txt_header = (TextView) findViewById(R.id.customheader_tv);
        relativeLayout_textViewArea.setOnClickListener(this);
        arraylist_addArea = new ArrayList&lt;CustomAreaModel&gt;();
        ListView_custom = (ListView) findViewById(R.id.List_add_custonArea);
        customArea_back_btn = (Button) findViewById(R.id.addcustonarea_back_btn);
        linear_listview = (LinearLayout) findViewById(R.id.linear_listview);
        customArea_back_btn.setOnClickListener(this);
        String getRoomName = getIntent().getStringExtra("roomname");
        txt_header.setText(getRoomName);
        adapterAddCustomArea = new AdapterAddCustomArea(Activity_Add_CustomArea.this, arraylist_addArea, false);
        ListView_custom.setAdapter(adapterAddCustomArea);
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.Relatve_txtview:
                CustomAreaModel text = new CustomAreaModel();
                text.setName("");
                arraylist_addArea.add(text);
            if(adapterAddCustomArea.getCount()&gt;3){
                LinearLayout.LayoutParams param1 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.20f);
                LinearLayout.LayoutParams param2 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1.80f);
                ListView_custom.setLayoutParams(param1);
                relativeLayout_textViewArea.setLayoutParams(param2);
                adapterAddCustomArea.notifyDataSetChanged();
            }else {
                adapterAddCustomArea.notifyDataSetChanged();
            }
                break;
            case R.id.addcustonarea_back_btn:
                finish();
                break;
        }
    }

    @Override
    public void deletePosition(int position) {
        arraylist_addArea.remove(position);
        if(adapterAddCustomArea.getCount()&gt;3){
            LinearLayout.LayoutParams param1 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.20f);
            LinearLayout.LayoutParams param2 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1.80f);
            ListView_custom.setLayoutParams(param1);
            relativeLayout_textViewArea.setLayoutParams(param2);
            adapterAddCustomArea.notifyDataSetChanged();
        }else {

            LinearLayout.LayoutParams param1 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT );
            LinearLayout.LayoutParams param2 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT );
            ListView_custom.setLayoutParams(param1);
            relativeLayout_textViewArea.setLayoutParams(param2);
            adapterAddCustomArea.notifyDataSetChanged();
        }
    }
    @Override
    public void setValueInModel(int position, String text) {
        if (arraylist_addArea.size() &lt; 1) {
            return;

        } else {
            if (arraylist_addArea.size() == position) {
                arraylist_addArea.get(position - 1).setName(text);
                adapterAddCustomArea.notifyDataSetChanged();
            } else {
                arraylist_addArea.get(position).setName(text);
                adapterAddCustomArea.notifyDataSetChanged();
            }
        }
    }
    protected void onResume() {
        //adapterAddCustomArea = new AdapterAddCustomArea(Activity_Add_CustomArea.this, arraylist_addArea,true);
        //   ListView_custom.setAdapter(adapterAddCustomArea);
        adapterAddCustomArea.notifyDataSetChanged();
        super.onResume();
    }

    //    public void delete(int position)
//    {
//        arraylist_addArea.remove(position);
//        adapterAddCustomArea = new AdapterAddCustomArea(MainActivity.this, arraylist_addArea);
//        ListView_custom.setAdapter(adapterAddCustomArea);
//    }
    private void scrollMyListViewToBottom() {
        ListView_custom.post(new Runnable() {
            @Override
            public void run() {
                // Select the last row so it will scroll into view...
                ListView_custom.setSelection(adapterAddCustomArea.getCount() - 1);
            }
        });
    }
}
</code></pre>

<p>Adapter Class</p>

<pre><code>public class AdapterAddCustomArea extends BaseAdapter {
    private Context mContext;
    List&lt;CustomAreaModel&gt; arraylist_addAreaAdapter;
    Activity_Add_CustomArea activity;
    public static final String MyPREFERENCES = "MyPrefs";

    String edt_value;
    String[] edtposition;
    public boolean isAdapterCalled = false;
    Map&lt;String, String&gt; areaName;

    public AdapterAddCustomArea(Context c, List&lt;CustomAreaModel&gt; addcustomArea, boolean isAdapterCalled) {
        this.mContext = c;
        activity = (Activity_Add_CustomArea) c;
        this.arraylist_addAreaAdapter = addcustomArea;
        this.isAdapterCalled = isAdapterCalled;
        areaName = new HashMap&lt;&gt;();
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return arraylist_addAreaAdapter.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return arraylist_addAreaAdapter;
    }
    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        final ViewHolder holder;
        LayoutInflater mInflater = (LayoutInflater) mContext
                .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.inflator_add_custom_area, null);
            holder = new ViewHolder();
            // holder.relatve_txtViewPlus = (RelativeLayout) convertView.findViewById(R.id.Relatve_txtview);
            holder.starLine_layout = (LinearLayout) convertView.findViewById(R.id.linear_starView);
            holder.layout_addArea_btn = (LinearLayout) convertView.findViewById(R.id.layout_add_button);
            holder.textView_addArea = (TextView) convertView.findViewById(R.id.addTextArea);
            holder.cross_image = (ImageView) convertView.findViewById(R.id.addcustom_cross_btn);
            holder.note_image = (ImageView) convertView.findViewById(R.id.AddcustomArea_Notes);
            holder.camera_image = (ImageView) convertView.findViewById(R.id.AddcustomArea_capture);
            holder.addArea_btn = (Button) convertView.findViewById(R.id.addArea_btnArea);
            holder.edit_addArea = (EditText) convertView.findViewById(R.id.AddcustomArea_txtview);
            holder.inflatorRoomDetail_firstStar = (ImageView) convertView.findViewById(R.id.inflatorRoomDetail_firstStar);
            holder.inflatorRoomDetail_twoStar = (ImageView) convertView.findViewById(R.id.inflatorRoomDetail_twoStar);
            holder.inflatorRoomDetail_threeStar = (ImageView) convertView.findViewById(R.id.inflatorRoomDetail_threeStar);
            holder.inflatorRoomDetail_fourStar = (ImageView) convertView.findViewById(R.id.inflatorRoomDetail_fourStar);
            holder.inflatorRoomDetail_fiveStar = (ImageView) convertView.findViewById(R.id.inflatorRoomDetail_fiveStar);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.cross_image.setTag(position);
        holder.edit_addArea.setText(arraylist_addAreaAdapter.get(position).getName());
        holder.edit_addArea.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (!hasFocus) {
                    //Toast.makeText(activity,holder.edit_addArea.getText().toString(),Toast.LENGTH_LONG).show();
                    activity.setValueInModel(position, holder.edit_addArea.getText().toString());
                }
            }
        });

        holder.addArea_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                arraylist_addAreaAdapter.get(position).setIsOpen(true);
                holder.starLine_layout.setVisibility(View.VISIBLE);
                holder.cross_image.setVisibility(View.GONE);
                holder.layout_addArea_btn.setVisibility(View.GONE);
                holder.edit_addArea.setVisibility(View.VISIBLE);
                holder.note_image.setVisibility(View.VISIBLE);
                holder.camera_image.setVisibility(View.VISIBLE);

            }
        });
        if (arraylist_addAreaAdapter.get(position).getNoOfRating() &gt; 0) {
            switch (arraylist_addAreaAdapter.get(position).getNoOfRating()) {
                case 1:
                    holder.inflatorRoomDetail_firstStar.setImageResource(R.drawable.onestarred);
                    holder.inflatorRoomDetail_twoStar.setImageResource(R.drawable.twostarview);
                    holder.inflatorRoomDetail_threeStar.setImageResource(R.drawable.threestar);
                    holder.inflatorRoomDetail_fiveStar.setImageResource(R.drawable.fivestar);
                    holder.starLine_layout.setVisibility(View.VISIBLE);
                    holder.layout_addArea_btn.setVisibility(View.GONE);
                    holder.cross_image.setVisibility(View.GONE);
                    break;
                case 2:
                    holder.inflatorRoomDetail_twoStar.setImageResource(R.drawable.twostargray);
                    holder.inflatorRoomDetail_firstStar.setImageResource(R.drawable.onestar);
                    holder.inflatorRoomDetail_threeStar.setImageResource(R.drawable.threestar);
                    holder.inflatorRoomDetail_fiveStar.setImageResource(R.drawable.fivestar);
                    holder.starLine_layout.setVisibility(View.VISIBLE);
                    holder.layout_addArea_btn.setVisibility(View.GONE);
                    holder.cross_image.setVisibility(View.GONE);
                    break;
                case 3:
                    holder.inflatorRoomDetail_threeStar.setImageResource(R.drawable.threestarorang);
                    holder.inflatorRoomDetail_firstStar.setImageResource(R.drawable.onestar);
                    holder.inflatorRoomDetail_twoStar.setImageResource(R.drawable.twostarview);
                    holder.inflatorRoomDetail_fiveStar.setImageResource(R.drawable.fivestar);
                    holder.starLine_layout.setVisibility(View.VISIBLE);
                    holder.layout_addArea_btn.setVisibility(View.GONE);
                    holder.cross_image.setVisibility(View.GONE);
                    break;
            }
        } else {
            if (arraylist_addAreaAdapter.get(position).isOpen()) {
                holder.starLine_layout.setVisibility(View.VISIBLE);
                holder.cross_image.setVisibility(View.GONE);
                holder.layout_addArea_btn.setVisibility(View.GONE);
                holder.edit_addArea.setVisibility(View.VISIBLE);
                holder.note_image.setVisibility(View.VISIBLE);
                holder.camera_image.setVisibility(View.VISIBLE);

            } else {
                holder.starLine_layout.setVisibility(View.GONE);
                holder.layout_addArea_btn.setVisibility(View.VISIBLE);
                holder.cross_image.setVisibility(View.VISIBLE);
                holder.note_image.setVisibility(View.GONE);
                holder.camera_image.setVisibility(View.GONE);
                holder.inflatorRoomDetail_firstStar.setImageResource(R.drawable.onestar);
                holder.inflatorRoomDetail_twoStar.setImageResource(R.drawable.twostarview);
                holder.inflatorRoomDetail_threeStar.setImageResource(R.drawable.threestar);
                holder.inflatorRoomDetail_fourStar.setImageResource(R.drawable.fourstar);
                holder.inflatorRoomDetail_fiveStar.setImageResource(R.drawable.fivestarblue);
            }
        }
        holder.cross_image.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                activity.deletePosition(position);
            }
        });
        holder.inflatorRoomDetail_firstStar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                arraylist_addAreaAdapter.get(position).setNoOfRating(1);
                Intent intent = new Intent(mContext, ActivityOpenGallery.class);
                intent.putExtra("flag", 1);
//              intent.putExtra("position",position);
                setRatingAndPosition(1, position);
                mContext.startActivity(intent);
                ((Activity) mContext).overridePendingTransition(R.anim.enter, R.anim.exit);
            }
        });
        holder.inflatorRoomDetail_twoStar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                arraylist_addAreaAdapter.get(position).setNoOfRating(2);
                Intent intent = new Intent(mContext, ActivityOpenGallery.class);
                intent.putExtra("flag", 2);
                setRatingAndPosition(2, position);
//              intent.putExtra("position",position);
                mContext.startActivity(intent);
                ((Activity) mContext).overridePendingTransition(R.anim.enter, R.anim.exit);
            }
        });
        holder.inflatorRoomDetail_threeStar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                arraylist_addAreaAdapter.get(position).setNoOfRating(3);
                Intent intent = new Intent(mContext, ActivityOpenGallery.class);
                intent.putExtra("flag", 3);
                setRatingAndPosition(3, position);
                mContext.startActivity(intent);
                ((Activity) mContext).overridePendingTransition(R.anim.enter, R.anim.exit);
            }
        });
        holder.inflatorRoomDetail_fourStar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final Dialog dialog = new Dialog(mContext);
                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                dialog.setContentView(R.layout.inventry_dialog_fourstar);
                Button dialogButtonOk = (Button) dialog.findViewById(R.id.dilaog_button_cancel);
                dialogButtonOk.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog.dismiss();
                    }
                });
                dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
                dialog.show();
            }
        });
        return convertView;
    }
    private class ViewHolder {
        //RelativeLayout relatve_txtViewPlus;
        TextView textView_addArea;
        ImageView cross_image, note_image, camera_image, inflatorRoomDetail_firstStar, inflatorRoomDetail_twoStar,
                inflatorRoomDetail_threeStar, inflatorRoomDetail_fourStar, inflatorRoomDetail_fiveStar;
        Button addArea_btn;
        LinearLayout starLine_layout,layout_addArea_btn;
        EditText edit_addArea;

    }
    public interface DeletePosition {
        public void deletePosition(int position);

        public void setValueInModel(int position, String text);
    }
    private void setRatingAndPosition(int rating, int position) {
        Activity_Add_CustomArea.starRating = rating;
        Activity_Add_CustomArea.starRatingPosition = position;
    }

}
</code></pre>