我有一个简单的ListActivity,它使用自定义ListAdapter在列表中生成视图.通常ListAdapter只会用TextViews填充视图,但现在我想在那里放一个按钮.
然而,根据我的理解和经验,在列表项中放置可聚焦视图可以防止在单击列表项时在ListActivity中触发onListItemClick().按钮仍然在列表项中正常运行,但是当按下按钮之外的其他内容时,我希望触发onListItemClick.
我怎样才能做到这一点?
我有一个listfragment,显示数据库中的列表.除了一件我无法清理的小物品外,我还能正常工作.列表视图看起来像这样.
-----------------------------------------------------
text text text | some more text | delete row button |
-----------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
我的问题:当用户按下删除行按钮行从数据库中删除,但不会从屏幕上,直到活动被停止并再次启动被删除.
我知道这notifyDataSetChanged()是更新这些列表的首选方法,但它似乎没有做任何事情......无论如何,下面是我notifyDataSetChanged()调用的游标适配器的代码.
public class CalcCursorAdapter extends SimpleCursorAdapter{
private Context mContext;
private ListView mListView;
private int mLayout;
private Cursor mcursor;
protected static class ViewHolder {
protected TextView text;
protected ImageButton button;
private int position;
}
@SuppressWarnings("deprecation")
public CalcCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to)
{
super(context, layout, c, from, to);
this.mContext = context;
this.mLayout = layout;
this.mcursor = c; …Run Code Online (Sandbox Code Playgroud)