【发布时间】:2014-01-31 04:26:04
【问题描述】:
0当我单击一个按钮时,我会在列表视图中填充一行。我膨胀的行包含两个按钮和一个图像视图。使用其中一个按钮,我可以从列表视图中删除膨胀的行。 我使用以下代码。
LayoutInflater vi = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View vv = vi.inflate(R.layout.row_event_datetime, null);
ImageButton ib = (ImageButton) vv.findViewById(R.id.ivCancel);
ib.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int i = ????
((LinearLayout) vv.getParent()).removeView(vv);
}
});
View insertPoint = findViewById(R.id.llAddActEventMoments);
((ViewGroup) insertPoint).addView(vv, 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
当我单击图像按钮 ivCancel 时,是否可以获得已删除行的列表视图中的位置?
【问题讨论】:
标签: android listview layout-inflater