1

我正在创建一个类似于 ContactEntry Activity 作为本机联系人应用程序的视图。我已成功完成此操作,但在编辑文本选择时遇到问题。我想首先将第一行的 EditText(组织名称)显示为光标可见,但 ListView 使第二行的 Edittext(电话号码)显示为光标可见,请同时查找附件图像。

请帮助我如何解决它。在此处输入图像描述

这是我的适配器类。

private class CustomItemEntryAdapter extends BaseAdapter{

    private LayoutInflater mInflator;
    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return 4;
    }

    public CustomItemEntryAdapter(Context context){
        mInflator = getLayoutInflater();
    }
    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return getItem(position);
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub

        ItemsToFillViewHolder holder = null;
        if(position==0){
            convertView = mInflator.inflate(R.layout.institution_name_cell, null);
            EditText edittext = (EditText)convertView.findViewById(R.id.editText_institution);
            edittext.setCursorVisible(true);
        }else{
            convertView = mInflator.inflate(R.layout.saving_account_cell, null);
        }

         if(position==1){
            if(map_CellView.containsKey(position)){
                convertView = map_CellView.get(position);

            }else{

                holder = new ItemsToFillViewHolder();
                convertView.setTag(position);
                holder.cellTitle = (TextView)convertView.findViewById(R.id.txt_saving_acc);
                holder.cellTitle.setText("Phone");
                holder.cellImage = (ImageView)convertView.findViewById(R.id.image_add);
                holder.cellImage.setTag(convertView);
                holder.cellImage.setOnClickListener(imageclickListener);
                AddDefaultCellToListView(convertView,position);
            }


        }else if(position==2){

            if(map_CellView.containsKey(position)){
                convertView = map_CellView.get(position);

            }else{

                holder = new ItemsToFillViewHolder();
                convertView.setTag(position);
                holder.cellTitle = (TextView)convertView.findViewById(R.id.txt_saving_acc);
                holder.cellTitle.setText("Email");
                holder.cellImage = (ImageView)convertView.findViewById(R.id.image_add);
                holder.cellImage.setTag(convertView);
                holder.cellImage.setOnClickListener(imageclickListener);
                AddDefaultCellToListView(convertView,position);
            }

        }else if(position==3){

            if(map_CellView.containsKey(position)){
                convertView = map_CellView.get(position);

            }else{

                holder = new ItemsToFillViewHolder();
                convertView.setTag(position);
                holder.cellTitle = (TextView)convertView.findViewById(R.id.txt_saving_acc);
                holder.cellTitle.setText("Address");
                holder.cellImage = (ImageView)convertView.findViewById(R.id.image_add);
                holder.cellImage.setTag(convertView);
                holder.cellImage.setOnClickListener(imageclickListener);
                AddDefaultCellToListView(convertView,position);
            }

        }
        return convertView;
    }

}

提前致谢。

4

2 回答 2

4

尝试这个...

EditText edittext = (EditText)convertView.findViewById(R.id.editText_institution);
edittext.requestFocus();
于 2013-02-04T07:32:44.237 回答
2

如果第二个(工作)editText 具有“requestFocus”属性,还请检查您的 xml。如果是这样,请将其删除。(并将其移至第一个 editText ,如 Muni 建议的那样)。

于 2013-02-04T08:11:04.173 回答