【发布时间】:2013-03-04 20:58:40
【问题描述】:
我有带有ListView 的片段,比如MyListFragment 和自定义CursorAdapter。
我在此适配器中为列表行中的按钮设置onClickListener。
public class MyListAdapter extends CursorAdapter {
public interface AdapterInterface {
public void buttonPressed();
}
...
@Override
public void bindView(final View view, final Context context, final Cursor cursor) {
ViewHolder holder = (ViewHolder) view.getTag();
...
holder.button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// some action
// need to notify MyListFragment
}
});
}
}
public MyListFragment extends Fragment implements AdapterInterface {
@Override
public void buttonPressed() {
// some action
}
}
我需要在按下按钮时通知片段。如何调用这个接口?
请帮忙。
【问题讨论】: