Back to project page task4java.
The source code is released under:
Apache License
If you think the Android project task4java listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Copyright (c) 2014 Andree Hagelstein, Maik Schulze, Deutsche Telekom AG. All Rights Reserved. * //from ww w . j a v a 2 s .c o m * Filename: ActivityUtils.java */ package com.task4java.android.activity; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import com.task4java.android.annotation.Annotations.ViewMapping; import com.task4java.lang.reflect.ReflectionCache; import android.app.Activity; import android.view.View; public class ActivityUtils { protected static void InitializeView(Activity activity) { for (Field classField : ReflectionCache.getClassFields(activity.getClass())) { try { Annotation[] annotations = ReflectionCache.getFieldAnnotations(classField); for (Annotation annotation : annotations) { if (annotation instanceof ViewMapping) { ViewMapping viewMapping = (ViewMapping) annotation; View view = activity.findViewById(viewMapping.resourceId()); if (view != null) { classField.setAccessible(true); classField.set(activity, view); } } } } catch (Exception ex) { ex.printStackTrace(); } } } }