當前位置: 首頁>>代碼示例>>Java>>正文


Java Activity.setContentView方法代碼示例

本文整理匯總了Java中android.app.Activity.setContentView方法的典型用法代碼示例。如果您正苦於以下問題:Java Activity.setContentView方法的具體用法?Java Activity.setContentView怎麽用?Java Activity.setContentView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.Activity的用法示例。


在下文中一共展示了Activity.setContentView方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: forActivity

import android.app.Activity; //導入方法依賴的package包/類
@Override public ViewGroup forActivity(final Activity activity) {
  activity.setContentView(R.layout.internal_activity_frame);
  ButterKnife.bind(this, activity);

  TelescopeLayout.cleanUp(activity); // Clean up any old screenshots.
  telescopeLayout.setLens(new BugReportLens(activity, lumberYard, intentManager));

  // If you have not seen the telescope dialog before, show it.
  if (!seenTelescopeDialog.get()) {
    telescopeLayout.postDelayed(() -> {
      if (activity.isFinishing()) {
        return;
      }

      seenTelescopeDialog.set(true);
      showTelescopeDialog(activity);
    }, 1000);
  }

  return telescopeLayout;
}
 
開發者ID:rogues-dev,項目名稱:superglue,代碼行數:22,代碼來源:TelescopeViewContainer.java

示例2: MainUIUtil

import android.app.Activity; //導入方法依賴的package包/類
private MainUIUtil(Activity activity){
    this.activity = activity;
    activity. setContentView(R.layout.activity_main2);
    viewPager = (ViewPager) activity.findViewById(R.id.vp_container);
    bottomTabLayout = (PagerBottomTabLayout) activity.findViewById(R.id.tab);


}
 
開發者ID:hss01248,項目名稱:MainActivityUIUtil,代碼行數:9,代碼來源:MainUIUtil.java

示例3: open

import android.app.Activity; //導入方法依賴的package包/類
public static void open(final Activity activity, String imageUrl, final OnWelcomeDone onWelcomeDone) {
    activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
    final View welcome = LayoutInflater.from(activity).inflate(R.layout.welcome, null);
    final AlphaAnimation alphaAnimation = new AlphaAnimation(0.0f, 1.0f);
    alphaAnimation.setDuration(1000);
    welcome.startAnimation(alphaAnimation);
    Glide.with(activity).load(imageUrl).into(((ImageView) welcome.findViewById(R.id.iv_welcome)));
    activity.setContentView(welcome);
    final TextView skipView = (TextView) welcome.findViewById(R.id.tv_skip);

    final CountDownTimer start = new CountDownTimer(5000, 1000) {
        @Override
        public void onTick(long millisUntilFinished) {
            skipView.setText("跳過" + ((millisUntilFinished / 1000) - 1));
        }

        @Override
        public void onFinish() {
            AlphaAnimation alphaAnimation1 = new AlphaAnimation(1.0f, 0.0f);
            alphaAnimation1.setDuration(1000);
            welcome.startAnimation(alphaAnimation1);
            if (onWelcomeDone != null) {
                onWelcomeDone.onDone();
            }
        }
    }.start();
    skipView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            start.onFinish();
        }
    });

}
 
開發者ID:TestSmirk,項目名稱:WelcomeView,代碼行數:36,代碼來源:WelcomeUtil.java

示例4: parse

import android.app.Activity; //導入方法依賴的package包/類
/**
 * 透過Activity解析LKUI注解
 * 可以通過注解配置contentView,field的id等
 */
public static void parse(Activity activity, boolean ignoreNoFindViewField) {
    try {
        // 解析類注解:SetContentView
        SetContentView setContentView = activity.getClass().getAnnotation(SetContentView.class);
        if (setContentView != null && setContentView.value() > 0)
            // 可以讀到SetContentView的layout的id值
            activity.setContentView(setContentView.value());
        // 解析屬性注解:FindView
        Field[] fields = activity.getClass().getDeclaredFields();
        for (Field fieldItem : fields) {
            fieldItem.setAccessible(true);
            if (!(View.class.isAssignableFrom(fieldItem.getType())))
                continue;
            FindView findView = fieldItem.getAnnotation(FindView.class);
            if (findView != null)
                // 配置了FindView注解
                if (findView.value() > 0)
                    fieldItem.set(activity, activity.findViewById(findView.value()));
                else // 如果沒有設置view的id,那麽自動嘗試以屬性名作為id進行查詢賦值
                    fieldItem.set(activity, LKResourceTool.findViewByIdStr(activity, fieldItem.getName()));
            else if (!ignoreNoFindViewField)// 沒有配置FindView注解並且沒有設置忽略無注解屬性(ignoreNoFindViewField為false),嘗試以屬性名作為id,進行查詢賦值
                fieldItem.set(activity, LKResourceTool.findViewByIdStr(activity, fieldItem.getName()));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
開發者ID:LemonAppCN,項目名稱:LemonKit4Android,代碼行數:33,代碼來源:LKUIAnnotationParser.java

示例5: attach

import android.app.Activity; //導入方法依賴的package包/類
public void attach(Activity activity, int layoutResID) {
    View root = getContainer(activity);
    View view = LayoutInflater.from(activity).inflate(layoutResID, null);
    swipeBackLayout.addView(view);
    activity.setContentView(root);
}
 
開發者ID:drakeet,項目名稱:rebase-android,代碼行數:7,代碼來源:SwipeBackDelegate.java

示例6: forActivity

import android.app.Activity; //導入方法依賴的package包/類
@Override public ViewGroup forActivity(final Activity activity) {
  activity.setContentView(R.layout.debug_activity_frame);

  final ViewHolder viewHolder = new ViewHolder();
  ButterKnife.bind(viewHolder, activity);

  final Context drawerContext = new ContextThemeWrapper(activity, R.style.Theme_SuperGlue_Debug);
  final DebugView debugView = new DebugView(drawerContext);
  viewHolder.debugDrawer.addView(debugView);

  viewHolder.drawerLayout.setDrawerShadow(R.drawable.debug_drawer_shadow, GravityCompat.END);
  viewHolder.drawerLayout.setDrawerListener(new DebugDrawerLayout.SimpleDrawerListener() {
    @Override public void onDrawerOpened(View drawerView) {
      debugView.onDrawerOpened();
    }
  });

  TelescopeLayout.cleanUp(activity); // Clean up any old screenshots.
  viewHolder.telescopeLayout.setLens(new BugReportLens(activity, lumberYard, intentManager));

  // If you have not seen the debug drawer before, show it with a message
  if (!seenDebugDrawer.get()) {
    viewHolder.drawerLayout.postDelayed(() -> {
      viewHolder.drawerLayout.openDrawer(GravityCompat.END);
      Toast.makeText(drawerContext, R.string.debug_drawer_welcome, Toast.LENGTH_LONG).show();
    }, SECONDS.toMillis(1));
    seenDebugDrawer.set(true);
  }

  final CompositeSubscription subscriptions = new CompositeSubscription();
  setupMadge(viewHolder, subscriptions);
  setupScalpel(viewHolder, subscriptions);

  final Application app = activity.getApplication();
  app.registerActivityLifecycleCallbacks(new EmptyActivityLifecycleCallbacks() {
    @Override public void onActivityDestroyed(Activity lifecycleActivity) {
      if (lifecycleActivity == activity) {
        subscriptions.unsubscribe();
        app.unregisterActivityLifecycleCallbacks(this);
      }
    }
  });

  riseAndShine(activity);
  return viewHolder.content;
}
 
開發者ID:rogues-dev,項目名稱:superglue,代碼行數:47,代碼來源:DebugViewContainer.java

示例7: setContentView

import android.app.Activity; //導入方法依賴的package包/類
/**
 * Set the Activity's content view to the given layout and return the associated binding.
 * The given layout resource must not be a merge layout.
 *
 * @param bindingComponent The DataBindingComponent to use in data binding.
 * @param activity The Activity whose content View should change.
 * @param layoutId The resource ID of the layout to be inflated, bound, and set as the
 *                 Activity's content.
 * @return The binding associated with the inflated content view.
 */
public static <T extends ViewDataBinding> T setContentView(Activity activity, int layoutId,
                                                           DataBindingComponent bindingComponent) {
    activity.setContentView(layoutId);
    View decorView = activity.getWindow().getDecorView();
    ViewGroup contentView = (ViewGroup) decorView.findViewById(android.R.id.content);
    return bindToAddedViews(bindingComponent, contentView, 0, layoutId);
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:18,代碼來源:AtlasDataBindingUtil.java


注:本文中的android.app.Activity.setContentView方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。