我正在创建一个类似于 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;
}
}
提前致谢。