当前位置: 首页>>代码示例>>Java>>正文


Java Activity.findViewById方法代码示例

本文整理汇总了Java中android.app.Activity.findViewById方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.findViewById方法的具体用法?Java Activity.findViewById怎么用?Java Activity.findViewById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Activity的用法示例。


在下文中一共展示了Activity.findViewById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startFullScreen

import android.app.Activity; //导入方法依赖的package包/类
@Override
public void startFullScreen() {
    if (mVideoController == null) return;
    Activity activity = WindowUtil.scanForActivity(mVideoController.getContext());
    if (activity == null) return;
    if (isFullScreen) return;
    WindowUtil.hideSystemBar(getContext());
    this.removeView(playerContainer);
    ViewGroup contentView = activity
            .findViewById(android.R.id.content);
    LayoutParams params = new LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    contentView.addView(playerContainer, params);
    orientationEventListener.enable();
    isFullScreen = true;
    mVideoController.setPlayerState(PLAYER_FULL_SCREEN);
}
 
开发者ID:dueeeke,项目名称:dkplayer,代码行数:19,代码来源:IjkVideoView.java

示例2: getVisibleDialog

import android.app.Activity; //导入方法依赖的package包/类
private static View getVisibleDialog(Activity activity) {
	View sideBar = activity.findViewById(R.id.modal_sidebar);
	View dialogActions = activity.findViewById(R.id.modal_dialog_actions);
	View dialogList = activity.findViewById(R.id.modal_dialog_list);
	View dialogChooser = activity.findViewById(R.id.modal_dialog_chooser);
	View gamepadDialog = activity.findViewById(R.id.modal_dialog_gamepad);
	View saveStateDialog = activity.findViewById(R.id.modal_dialog_savestates);
	View loginDialog = activity.findViewById(R.id.modal_dialog_login);
	View customDialog = activity.findViewById(R.id.modal_dialog_custom);
	
	View dialog =
		isVisible(gamepadDialog)? gamepadDialog :
		isVisible(dialogActions)? dialogActions :
		isVisible(dialogList)   ? dialogList :
		isVisible(dialogChooser)   ? dialogChooser :
		isVisible(saveStateDialog) ? saveStateDialog :
		isVisible(loginDialog) ? loginDialog : 
		isVisible(customDialog) ? customDialog :
		isVisible(sideBar)      ? sideBar : null;
	return dialog;
}
 
开发者ID:fcatrin,项目名称:retroxlibs,代码行数:22,代码来源:RetroBoxDialog.java

示例3: onProgressChanged

import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    Activity activity = (Activity) seekBar.getContext();

    SeekBar redBar = activity.findViewById(R.id.RedBar);
    float red = (redBar.getProgress()+1);
    red = red/100;

    SeekBar greenBar = activity.findViewById(R.id.GreenBar);
    float green = (greenBar.getProgress()+1);
    green = green/100;

    SeekBar blueBar = activity.findViewById(R.id.BlueBar);
    float blue = (blueBar.getProgress()+1);
    blue = blue/100;

    helper.sh(String.format("killall echo; echo 1015 i32 1 f %f f 0 f 0 f 0 f 0 f %f f 0 f 0 f 0 f 0 f %f f 0 f 0 f 0 f 0 f 1 > %s &", red, green, blue, activity.getCacheDir()+"/pipe"));
}
 
开发者ID:LibreShift,项目名称:OpenShift,代码行数:19,代码来源:SeekBarListener.java

示例4: setColorDiff

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 设置状态栏颜色(5.0以下无半透明效果,不建议使用)
 *
 * @param activity 需要设置的 activity
 * @param color    状态栏颜色值
 */
@Deprecated
public static void setColorDiff(Activity activity, @ColorInt int color) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return;
    }
    transparentStatusBar(activity);
    ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
    // 移除半透明矩形,以免叠加
    View fakeStatusBarView = contentView.findViewById(FAKE_STATUS_BAR_VIEW_ID);
    if (fakeStatusBarView != null) {
        if (fakeStatusBarView.getVisibility() == View.GONE) {
            fakeStatusBarView.setVisibility(View.VISIBLE);
        }
        fakeStatusBarView.setBackgroundColor(color);
    } else {
        contentView.addView(createStatusBarView(activity, color));
    }
    setRootView(activity);
}
 
开发者ID:Lingzh0ng,项目名称:BrotherWeather,代码行数:26,代码来源:XStatusBar.java

示例5: onCreate

import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (getArguments().containsKey(ARG_ITEM_ID)) {
        // Load the dummy content specified by the fragment
        // arguments. In a real-world scenario, use a Loader
        // to load content from a content provider.
        mItem = DummyContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));

        Activity activity = this.getActivity();
        CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout);
        if (appBarLayout != null) {
            appBarLayout.setTitle(mItem.content);
        }
    }
}
 
开发者ID:yrom,项目名称:shrinker,代码行数:18,代码来源:ItemDetailFragment.java

示例6: ActivityDrawListener

import android.app.Activity; //导入方法依赖的package包/类
private ActivityDrawListener(Activity activity)
{
    FrameLayout frameLayout = activity.findViewById(android.R.id.content);
    if (frameLayout == null)
    {
        throw new NullPointerException("android.R.id.content container not found in activity");
    }
    frameLayout.getViewTreeObserver().addOnPreDrawListener(this);
}
 
开发者ID:zj565061763,项目名称:poper,代码行数:10,代码来源:ActivityDrawListener.java

示例7: getToolbarNavigationContentDescription

import android.app.Activity; //导入方法依赖的package包/类
/**
 * Returns the content description for the navigation button view in the toolbar.
 */
public static String getToolbarNavigationContentDescription(
        @NonNull Activity activity, @IdRes int toolbar1) {
    Toolbar toolbar = (Toolbar) activity.findViewById(toolbar1);
    if (toolbar != null) {
        return (String) toolbar.getNavigationContentDescription();
    } else {
        throw new RuntimeException("No toolbar found.");
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:TestUtils.java

示例8: addTranslucentView

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 添加半透明矩形条
 *
 * @param activity       需要设置的 activity
 * @param statusBarAlpha 透明值
 */
private static void addTranslucentView(Activity activity, int statusBarAlpha) {
    ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
    // 移除半透明矩形,以免叠加
    if (contentView.getChildCount() > 1) {
        contentView.removeViewAt(1);
    }
    contentView.addView(createTranslucentStatusBarView(activity, statusBarAlpha));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:StatusBarUtil.java

示例9: setRootView

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 设置根布局参数
 */
private static void setRootView(Activity activity) {
    ViewGroup parent = (ViewGroup) activity.findViewById(android.R.id.content);
    for (int i = 0, count = parent.getChildCount(); i < count; i++) {
        View childView = parent.getChildAt(i);
        if (childView instanceof ViewGroup) {
            childView.setFitsSystemWindows(true);
            ((ViewGroup) childView).setClipToPadding(true);
        }
    }
}
 
开发者ID:hushengjun,项目名称:FastAndroid,代码行数:14,代码来源:UIStatusBarController.java

示例10: setStatusBarColor

import android.app.Activity; //导入方法依赖的package包/类
static void setStatusBarColor(Activity activity, int statusColor) {
    Window window = activity.getWindow();
    //设置Window为全透明
    window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

    ViewGroup mContentView = (ViewGroup) window.findViewById(Window.ID_ANDROID_CONTENT);
    //获取父布局
    View mContentChild = mContentView.getChildAt(0);
    //获取状态栏高度
    int statusBarHeight = getStatusBarHeight(activity);

    //如果已经存在假状态栏则移除,防止重复添加
    removeFakeStatusBarViewIfExist(activity);
    //添加一个View来作为状态栏的填充
    addFakeStatusBarView(activity, statusColor, statusBarHeight);
    //设置子控件到状态栏的间距
    addMarginTopToContentChild(mContentChild, statusBarHeight);
    //不预留系统栏位置
    if (mContentChild != null) {
        ViewCompat.setFitsSystemWindows(mContentChild, false);
    }
    //如果在Activity中使用了ActionBar则需要再将布局与状态栏的高度跳高一个ActionBar的高度,否则内容会被ActionBar遮挡
    int action_bar_id = activity.getResources().getIdentifier("action_bar", "id", activity.getPackageName());
    View view = activity.findViewById(action_bar_id);
    if (view != null) {
       TypedValue typedValue = new TypedValue();
        if (activity.getTheme().resolveAttribute(R.attr.actionBarSize, typedValue, true)) {
            int actionBarHeight = TypedValue.complexToDimensionPixelSize(typedValue.data, activity.getResources().getDisplayMetrics());
            Eyes.setContentTopPadding(activity, actionBarHeight);
        }
    }
}
 
开发者ID:bigjelly,项目名称:ShaddockVideoPlayer,代码行数:33,代码来源:EyesKitKat.java

示例11: setupStatusBarView

import android.app.Activity; //导入方法依赖的package包/类
@NonNull
private View setupStatusBarView(@NonNull Activity activity) {
    ViewGroup contentViewGroup = (ViewGroup) activity.findViewById(android.R.id.content);
    View statusBarView = new View(activity);
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ImmerseGlobalConfig.getInstance().getStatusBarHeight());
    contentViewGroup.addView(statusBarView, params);
    return statusBarView;
}
 
开发者ID:ls1110924,项目名称:ImmerseMode,代码行数:10,代码来源:TlSbTlNbImmerseMode.java

示例12: translucentStatusBar

import android.app.Activity; //导入方法依赖的package包/类
/**
 * change to full screen mode
 * @param hideStatusBarBackground hide status bar alpha Background when SDK > 21, true if hide it
 */
public static void translucentStatusBar(Activity activity, boolean hideStatusBarBackground) {
    Window window = activity.getWindow();
    ViewGroup mContentView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT);

    //set child View not fill the system window
    View mChildView = mContentView.getChildAt(0);
    if (mChildView != null) {
        ViewCompat.setFitsSystemWindows(mChildView, false);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        int statusBarHeight = getStatusBarHeight(activity);

        //First translucent status bar.
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            //After LOLLIPOP just set LayoutParams.
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            if (hideStatusBarBackground) {
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                window.setStatusBarColor(COLOR_TRANSLUCENT);
            } else {
                window.setStatusBarColor(calculateStatusBarColor(COLOR_TRANSLUCENT, DEFAULT_COLOR_ALPHA));
            }
            //must call requestApplyInsets, otherwise it will have space in screen bottom
            if (mChildView != null) {
                ViewCompat.requestApplyInsets(mChildView);
            }
        } else {
            ViewGroup mDecorView = (ViewGroup) window.getDecorView();
            if (mDecorView.getTag() != null && mDecorView.getTag() instanceof Boolean && (Boolean)mDecorView.getTag()) {
                mChildView = mDecorView.getChildAt(0);
                //remove fake status bar view.
                mContentView.removeView(mChildView);
                mChildView = mContentView.getChildAt(0);
                if (mChildView != null) {
                    FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mChildView.getLayoutParams();
                    //cancel the margin top
                    if (lp != null && lp.topMargin >= statusBarHeight) {
                        lp.topMargin -= statusBarHeight;
                        mChildView.setLayoutParams(lp);
                    }
                }
                mDecorView.setTag(false);
            }
        }
    }
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:53,代码来源:StatusBarCompat.java

示例13: getPictureFail

import android.app.Activity; //导入方法依赖的package包/类
/**
 * Called upon failure to get picture
 * @param ctx
 */
public static void getPictureFail(Activity ctx) {
    DummyMainActivity.toastMe("Failed to get pic", ctx);
    ImageView picPreview = (ImageView) ctx.findViewById(R.id.pic_preview);
    picPreview.setImageBitmap(null);
}
 
开发者ID:CMPUT301F17T17,项目名称:Habitizer,代码行数:10,代码来源:AddHabitEventActivity.java

示例14: WebViewHelper

import android.app.Activity; //导入方法依赖的package包/类
public WebViewHelper(Activity activity, UIManager uiManager) {
    this.activity = activity;
    this.uiManager = uiManager;
    this.webView = (WebView) activity.findViewById(R.id.webView);
    this.webSettings = webView.getSettings();
}
 
开发者ID:xtools-at,项目名称:Android-PWA-Wrapper,代码行数:7,代码来源:WebViewHelper.java

示例15: findById

import android.app.Activity; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <T extends View> T findById(@NonNull Activity parent, @IdRes int resId) {
  return (T) parent.findViewById(resId);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:5,代码来源:ViewUtil.java


注:本文中的android.app.Activity.findViewById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。