本文整理汇总了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;
}
示例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);
}
示例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();
}
});
}
示例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();
}
}
示例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);
}
示例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;
}
示例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);
}