如何在片段和适配器之间创建接口?
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 }}
慕的地10843