首页 > 代码库 > Android_View_得到Activity

Android_View_得到Activity


Context context = view.getContext();
if (context instanceof Activity){
	Activity activity = (Activity)context;
}


//应用
public View.OnClickListener onClickListener = new View.OnClickListener() {
	public void onClick(View v) {
		Activity currentActivity = (Activity) v.getContext();
		Intent i = new Intent(currentActivity, ScreenTransitionLab.class);
		currentActivity.startActivity(i);
	}
};

Android_View_得到Activity