本文整理汇总了Java中android.view.View.getClass方法的典型用法代码示例。如果您正苦于以下问题:Java View.getClass方法的具体用法?Java View.getClass怎么用?Java View.getClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.getClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isSameLayout
import android.view.View; //导入方法依赖的package包/类
/**
* Tell if two layout view is from the same skin.
*
* @param currentView View from <code>ResourceManager.getView() </code> used currently.
* @param newView View from <code>ResourceManager.getView() </code> after change skin.
* @return true if same layout, false otherwise.
*/
public static boolean isSameLayout(View currentView, View newView) {
if (currentView == newView) {
return true;
}
if (currentView == null || newView == null) {
return false;
}
if (currentView.getClass() != newView.getClass()) {
return false;
}
Object currentTag = currentView.getTag(LAYOUT_TAG_ID);
Object newTag = newView.getTag(LAYOUT_TAG_ID);
if (currentTag == newTag) {
return true;
}
if (currentTag == null || newTag == null) {
return false;
}
return currentTag.equals(newTag);
}
示例2: getView
import android.view.View; //导入方法依赖的package包/类
/**
* 返回等于指定class的所有view
*
* @param clazz
* @return
*/
public List<View> getView(Class clazz)
{
if (clazz == null || mMapView.isEmpty())
{
return null;
}
List<View> list = new ArrayList<>();
for (Map.Entry<View, Integer> item : mMapView.entrySet())
{
View view = item.getKey();
if (view != null && view.getClass() == clazz)
{
list.add(view);
}
}
return list;
}
示例3: getFirstView
import android.view.View; //导入方法依赖的package包/类
/**
* 返回等于指定class的第一个view
*
* @param clazz
* @return
*/
public View getFirstView(Class clazz)
{
if (clazz == null || mMapView.isEmpty())
{
return null;
}
for (Map.Entry<View, Integer> item : mMapView.entrySet())
{
View view = item.getKey();
if (view != null && view.getClass() == clazz)
{
return view;
}
}
return null;
}
示例4: getResolvedLayoutParams
import android.view.View; //导入方法依赖的package包/类
LayoutParams getResolvedLayoutParams(View child) {
final LayoutParams result = (LayoutParams) child.getLayoutParams();
if (!result.mBehaviorResolved) {
Class<?> childClass = child.getClass();
DefaultBehavior defaultBehavior = null;
while (childClass != null &&
(defaultBehavior = childClass.getAnnotation(DefaultBehavior.class)) == null) {
childClass = childClass.getSuperclass();
}
if (defaultBehavior != null) {
try {
result.setBehavior(
defaultBehavior.value().getDeclaredConstructor().newInstance());
} catch (Exception e) {
Log.e(TAG, "Default behavior class " + defaultBehavior.value().getName() +
" could not be instantiated. Did you forget a default constructor?", e);
}
}
result.mBehaviorResolved = true;
}
return result;
}
示例5: getResolvedLayoutParams
import android.view.View; //导入方法依赖的package包/类
LayoutParams getResolvedLayoutParams(View child) {
LayoutParams result = (LayoutParams) child.getLayoutParams();
if (!result.mBehaviorResolved) {
DefaultBehavior defaultBehavior = null;
for (Class<?> childClass = child.getClass(); childClass != null; childClass = childClass.getSuperclass()) {
defaultBehavior = (DefaultBehavior) childClass.getAnnotation(DefaultBehavior.class);
if (defaultBehavior != null) {
break;
}
}
if (defaultBehavior != null) {
try {
result.setBehavior((Behavior) defaultBehavior.value().newInstance());
} catch (Exception e) {
Log.e(TAG, "Default behavior class " + defaultBehavior.value().getName() + " could not be instantiated. Did you forget a default constructor?", e);
}
}
result.mBehaviorResolved = true;
}
return result;
}
示例6: tintEdgeEffect
import android.view.View; //导入方法依赖的package包/类
/**
* Tint the edge effect when you reach the end of a scroll view. API 21+ only
*
* @param scrollableView the scrollable view, such as a {@link android.widget.ScrollView}
* @param color the color
* @return true if it worked, false if it did not
*/
@TargetApi(21)
public static boolean tintEdgeEffect(@NonNull View scrollableView, @ColorInt int color) {
//http://stackoverflow.com/questions/27104521/android-lollipop-scrollview-edge-effect-color
boolean outcome = false;
final String[] edgeGlows = {"mEdgeGlowTop", "mEdgeGlowBottom", "mEdgeGlowLeft", "mEdgeGlowRight"};
for (String edgeGlow : edgeGlows) {
Class<?> clazz = scrollableView.getClass();
while (clazz != null) {
try {
final Field edgeGlowField = clazz.getDeclaredField(edgeGlow);
edgeGlowField.setAccessible(true);
final EdgeEffect edgeEffect = (EdgeEffect) edgeGlowField.get(scrollableView);
edgeEffect.setColor(color);
outcome = true;
break;
} catch (Exception e) {
clazz = clazz.getSuperclass();
}
}
}
return outcome;
}
示例7: setSearchViewContentColor
import android.view.View; //导入方法依赖的package包/类
public static void setSearchViewContentColor(View searchView, final @ColorInt int color) {
if (searchView == null) return;
final Class<?> cls = searchView.getClass();
try {
final Field mSearchSrcTextViewField = cls.getDeclaredField("mSearchSrcTextView");
mSearchSrcTextViewField.setAccessible(true);
final EditText mSearchSrcTextView = (EditText) mSearchSrcTextViewField.get(searchView);
mSearchSrcTextView.setTextColor(color);
mSearchSrcTextView.setHintTextColor(ATEUtil.adjustAlpha(color, 0.5f));
TintHelper.setCursorTint(mSearchSrcTextView, color);
Field field = cls.getDeclaredField("mSearchButton");
tintImageView(searchView, field, color);
field = cls.getDeclaredField("mGoButton");
tintImageView(searchView, field, color);
field = cls.getDeclaredField("mCloseButton");
tintImageView(searchView, field, color);
field = cls.getDeclaredField("mVoiceButton");
tintImageView(searchView, field, color);
} catch (Exception e) {
e.printStackTrace();
}
}
示例8: findViewWithType
import android.view.View; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <T extends View> T findViewWithType(ViewGroup viewGroup, Class<T> clazz) {
for (int i = 0; i < viewGroup.getChildCount() - 1; i++) {
View view = viewGroup.getChildAt(i);
if (view.getClass() == clazz) {
return (T) view;
}
}
return null;
}
示例9: get
import android.view.View; //导入方法依赖的package包/类
@Nullable
public static StyleHandler get(View view) {
Class<? extends View> vClazz = view.getClass();
StyleHandler styleHandler = sAttrHandlerCache.get(vClazz);
if (styleHandler == null) {
styleHandler = byClass(vClazz);
if (styleHandler != null) {
sAttrHandlerCache.put(vClazz, styleHandler);
}
}
return styleHandler;
}
示例10: process
import android.view.View; //导入方法依赖的package包/类
@Override
public void process(@NonNull Context context, @Nullable String key, @Nullable View target, @Nullable Integer tintColor) {
if (target == null)
return;
if (tintColor == null) {
// TODO pass a toolbar here?
final int toolbarColor = Config.toolbarColor(context, key, null);
tintColor = Config.getToolbarTitleColor(context, null, key, toolbarColor);
}
final Class<?> cls = target.getClass();
try {
final Field mSearchSrcTextViewField = cls.getDeclaredField("mSearchSrcTextView");
mSearchSrcTextViewField.setAccessible(true);
final EditText mSearchSrcTextView = (EditText) mSearchSrcTextViewField.get(target);
mSearchSrcTextView.setTextColor(tintColor);
mSearchSrcTextView.setHintTextColor(ContextCompat.getColor(context, ATEUtil.isColorLight(tintColor) ? R.color.ate_text_disabled_dark : R.color.ate_text_disabled_light));
TintHelper.setCursorTint(mSearchSrcTextView, tintColor);
Field field = cls.getDeclaredField("mSearchButton");
tintImageView(target, field, tintColor);
field = cls.getDeclaredField("mGoButton");
tintImageView(target, field, tintColor);
field = cls.getDeclaredField("mCloseButton");
tintImageView(target, field, tintColor);
field = cls.getDeclaredField("mVoiceButton");
tintImageView(target, field, tintColor);
} catch (Exception e) {
e.printStackTrace();
}
}
示例11: isDecorView
import android.view.View; //导入方法依赖的package包/类
private static boolean isDecorView(@NonNull View view) {
Class<?> clazz = view.getClass();
return clazz.getAnnotation(DecorView.class) != null;
}
示例12: isDecorView
import android.view.View; //导入方法依赖的package包/类
private static boolean isDecorView(View view) {
Class<?> clazz = view.getClass();
return clazz.getAnnotation(DecorView.class) != null;
}
示例13: isDecorView
import android.view.View; //导入方法依赖的package包/类
private static boolean isDecorView(View view) {
Class<?> clazz = view.getClass();
return clazz.getAnnotation(YViewPagerNew.DecorView.class) != null;
}
示例14: isDecorView
import android.view.View; //导入方法依赖的package包/类
private static boolean isDecorView(@NonNull View view) {
Class<?> clazz = view.getClass();
return clazz.getAnnotation(YViewPagerOrigin.DecorView.class) != null;
}
示例15: isDecorView
import android.view.View; //导入方法依赖的package包/类
private static boolean isDecorView(@NonNull View view) {
Class<?> clazz = view.getClass();
return clazz.getAnnotation(ViewPager.DecorView.class) != null;
}