什么getActivity()意思?我在某个地方看到,他们写的MainActivity.this.startActionMode(mActionModeCallback)不是getActivity().有人可以解释这两行是什么意思吗?
someView.setOnLongClickListener(new View.OnLongClickListener() {
// Called when the user long-clicks on someView
public boolean onLongClick(View view) {
if (mActionMode != null) {
return false;
}
// Start the CAB using the ActionMode.Callback defined above
mActionMode = getActivity().startActionMode(mActionModeCallback);
view.setSelected(true);
return true;
}
});
Run Code Online (Sandbox Code Playgroud) android ×1