在列表视图中,我在按钮点击时动态添加和删除列表的行(项目),在单个列表行(项目)中有两个edittexts,我已经尽力在自定义列表视图中获取editext的值pojo类,但不能这样做,甚至没有明智地获得所有edittext的值。
请提前帮助我,谢谢!
public static void GetImages()
{
var doc = PresentationDocument.Open(@"D:\Peak Sourcing\Work\ppt_test\xx.pptx", true);
var presentationPart = doc.PresentationPart;
var slidePart = presentationPart.GetPartsOfType<SlidePart>().First();
var imagePart = slidePart.GetPartsOfType<ImagePart>().First();
var stream = imagePart.GetStream();
var img = Image.FromStream(stream);
img.Save(@"D:\Peak Sourcing\Work\ppt_test\test-output.png");
}
我已经尝试了这两种方法,但没有得到任何解决方案。
for(int i = 0; i
private class NewCoachExerienceEditAdapter extends BaseAdapter {
@Override
public int getCount() {
if (newCoachProExpArrList != null) {
return newCoachProExpArrList.size();
} else {
return 0;
}
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView( final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
LayoutInflater inflater = UserEditProfileCoachActivity.this.getLayoutInflater();
convertView = inflater.inflate(R.layout.new_edit_pro_exp_row, null);
holder.et_coach_edit_pro_exp_academy_name = (EditText) convertView.findViewById(R.id.et_coach_edit_pro_exp_academy_name);
holder.et_edit_coach_pro_exp_comments = (EditText) convertView.findViewById(R.id.et_edit_coach_pro_exp_comments);
holder.iv_edit_coach_pro_exp_add = (ImageView) convertView.findViewById(R.id.iv_edit_coach_pro_exp_add);
holder.iv_edit_coach_pro_exp_remove = (ImageView) convertView.findViewById(R.id.iv_edit_coach_pro_exp_remove);
holder.ll_coach_edit_pro_exp_from = (LinearLayout) convertView.findViewById(R.id.ll_coach_edit_pro_exp_from);
holder.ll_coach_edit_pro_exp_to = (LinearLayout) convertView.findViewById(R.id.ll_coach_edit_pro_exp_to);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
newCoachProExperienceItem = newCoachProExpArrList.get(position);
holder.ref = position;
tv_edit_coach_edit_pro_exp_from = (TextView) convertView.findViewById(R.id.tv_edit_coach_edit_pro_exp_from);
tv_edit_coach_edit_pro_exp_to = (TextView) convertView.findViewById(R.id.tv_edit_coach_edit_pro_exp_to);
holder.et_coach_edit_pro_exp_academy_name.setText(newCoachProExperienceItem.getCoach_exp_academy_str());
holder.et_edit_coach_pro_exp_comments.setText(newCoachProExperienceItem.getCoach_exp_coach_comment_str());
holder.iv_edit_coach_pro_exp_add.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
newCoachProExperienceItem = new NewCoachProExperienceItem();
newCoachProExpArrList.add(newCoachProExperienceItem);
notifyDataSetChanged();
}
});
holder.iv_edit_coach_pro_exp_remove.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
newCoachProExpArrList.remove(position);
notifyDataSetChanged();
}
});
holder.et_coach_edit_pro_exp_academy_name.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
}
@Override
public void afterTextChanged(Editable arg0) {
newCoachProExpArrList.get(position).setCoach_exp_academy_str(arg0.toString());
Log.e(position + " : ", arg0.toString());
}
});
return convertView;
}
}
private class ViewHolder {
EditText et_edit_coach_pro_exp_comments, et_coach_edit_pro_exp_academy_name;
ImageView iv_edit_coach_pro_exp_add, iv_edit_coach_pro_exp_remove;
LinearLayout ll_coach_edit_pro_exp_from, ll_coach_edit_pro_exp_to;
int ref;
}
答案 0 :(得分:0)
我认为ViewHolder中存在问题。如果要添加或删除项目,可以生成所需的所有可见视图的项目布局,而不是在视图持有者中注册所有视图,例如,如果必须删除按钮上的某些视图,请执行viewHolder.someView.setVisibility(View.GONE);或者显示viewHolder.someView.setVisibility(View.VISIBLE);但我不认为这是最好的解决方案。
答案 1 :(得分:0)
我有两个选择,不一定是我需要的东西,反正两个方面如下:首先打开一个弹出窗口然后添加新行并通知适配器,第二个是动态增加listview的大小。