getActivity()
의 의미는 무엇입니까? 나는 어딘가에서 보았는데 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;
}
});
'getActivity()'는 Android API가 아닌 사용자 정의 메소드입니다. 더 많은 코드를 게시 할 수 있습니까? 특히 이것이 Activty 또는 다른 것을 확장하는 클래스에 있는지 알고 싶습니다. –
조각을 사용하면 문맥을 얻는 유일한 방법입니다 –