當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。