Tabnine Logo
Activity.setContentView
Code IndexAdd Tabnine to your IDE (free)

How to use
setContentView
method
in
android.app.Activity

Best Java code snippets using android.app.Activity.setContentView (Showing top 20 results out of 522)

origin: GitLqr/LQRWeChat

public void onCreate() {
  activity.getWindow().setBackgroundDrawable(new ColorDrawable(0x4c000000));
  sivViewer = new ScaledImageView(activity);
  sivViewer.setScaleType(ScaleType.MATRIX);
  activity.setContentView(sivViewer);
  if (pic != null) {
    sivViewer.getViewTreeObserver().addOnGlobalLayoutListener(this);
  }
}
origin: jaydenxiao2016/AndroidFire

public void onCreate() {
  activity.getWindow().setBackgroundDrawable(new ColorDrawable(0x4c000000));
  sivViewer = new ScaledImageView(activity);
  sivViewer.setScaleType(ScaleType.MATRIX);
  activity.setContentView(sivViewer);
  if (pic != null) {
    sivViewer.getViewTreeObserver().addOnGlobalLayoutListener(this);
  }
}
origin: Justson/AgentWeb

@Override
public DefaultWebCreator create() {
  if (mIsCreated) {
    return this;
  }
  mIsCreated = true;
  ViewGroup mViewGroup = this.mViewGroup;
  if (mViewGroup == null) {
    mViewGroup = this.mFrameLayout = (FrameLayout) createLayout();
    mActivity.setContentView(mViewGroup);
  } else {
    if (mIndex == -1) {
      mViewGroup.addView(this.mFrameLayout = (FrameLayout) createLayout(), mLayoutParams);
    } else {
      mViewGroup.addView(this.mFrameLayout = (FrameLayout) createLayout(), mIndex, mLayoutParams);
    }
  }
  return this;
}
origin: GitLqr/LQRWeChat

public void onCreate() {
  super.onCreate();
  int screenHeight = ResHelper.getScreenHeight(activity);
  float ratio = ((float) screenHeight) / DESIGN_SCREEN_HEIGHT;
  maxBodyHeight = 0;
  llPage = new LinearLayout(activity);
  llPage.setOrientation(LinearLayout.VERTICAL);
  activity.setContentView(llPage);
  rlTitle = new RelativeLayout(activity);
  rlTitle.setBackgroundColor(0xffe6e9ec);
  int titleHeight = (int) (DESIGN_TITLE_HEIGHT * ratio);
  LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, titleHeight);
  llPage.addView(rlTitle, lp);
  initTitle(rlTitle, ratio);
  RelativeLayout rlBody = new RelativeLayout(activity);
  rlBody.setBackgroundColor(0xffffffff);
  lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
  llPage.addView(rlBody, lp);
  initBody(rlBody, ratio);
  LinearLayout llShadow = new LinearLayout(activity);
  llShadow.setOrientation(LinearLayout.VERTICAL);
  rlBody.addView(llShadow, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
  initShadow(llShadow, ratio);
  llBottom = new LinearLayout(activity);
  llBottom.setOrientation(LinearLayout.VERTICAL);
  lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
  llPage.addView(llBottom, lp);
  initBottom(llBottom, ratio);
}
origin: jaydenxiao2016/AndroidFire

public void onCreate() {
  super.onCreate();
  int screenHeight = R.getScreenHeight(activity);
  float ratio = ((float) screenHeight) / DESIGN_SCREEN_WIDTH;
  maxBodyHeight = 0;
  llPage = new LinearLayout(activity);
  llPage.setOrientation(LinearLayout.VERTICAL);
  activity.setContentView(llPage);
  rlTitle = new RelativeLayout(activity);
  rlTitle.setBackgroundColor(0xffe6e9ec);
  int titleHeight = (int) (DESIGN_TITLE_HEIGHT_L * ratio);
  LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, titleHeight);
  llPage.addView(rlTitle, lp);
  initTitle(rlTitle, ratio);
  RelativeLayout rlBody = new RelativeLayout(activity);
  rlBody.setBackgroundColor(0xffffffff);
  lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
  llPage.addView(rlBody, lp);
  initBody(rlBody, ratio);
  LinearLayout llShadow = new LinearLayout(activity);
  llShadow.setOrientation(LinearLayout.VERTICAL);
  rlBody.addView(llShadow, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
  initShadow(llShadow, ratio);
  llBottom = new LinearLayout(activity);
  llBottom.setOrientation(LinearLayout.VERTICAL);
  lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
  llPage.addView(llBottom, lp);
  initBottom(llBottom, ratio);
}
origin: GitLqr/LQRWeChat

public void onCreate() {
  super.onCreate();
  int screenHeight = ResHelper.getScreenHeight(activity);
  float ratio = ((float) screenHeight) / DESIGN_SCREEN_WIDTH;
  maxBodyHeight = 0;
  llPage = new LinearLayout(activity);
  llPage.setOrientation(LinearLayout.VERTICAL);
  activity.setContentView(llPage);
  rlTitle = new RelativeLayout(activity);
  rlTitle.setBackgroundColor(0xffe6e9ec);
  int titleHeight = (int) (DESIGN_TITLE_HEIGHT_L * ratio);
  LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, titleHeight);
  llPage.addView(rlTitle, lp);
  initTitle(rlTitle, ratio);
  RelativeLayout rlBody = new RelativeLayout(activity);
  rlBody.setBackgroundColor(0xffffffff);
  lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
  llPage.addView(rlBody, lp);
  initBody(rlBody, ratio);
  LinearLayout llShadow = new LinearLayout(activity);
  llShadow.setOrientation(LinearLayout.VERTICAL);
  rlBody.addView(llShadow, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
  initShadow(llShadow, ratio);
  llBottom = new LinearLayout(activity);
  llBottom.setOrientation(LinearLayout.VERTICAL);
  lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
  llPage.addView(llBottom, lp);
  initBottom(llBottom, ratio);
}
origin: jaydenxiao2016/AndroidFire

public void onCreate() {
  super.onCreate();
  int screenHeight = R.getScreenHeight(activity);
  float ratio = ((float) screenHeight) / DESIGN_SCREEN_HEIGHT;
  maxBodyHeight = 0;
  llPage = new LinearLayout(activity);
  llPage.setOrientation(LinearLayout.VERTICAL);
  activity.setContentView(llPage);
  rlTitle = new RelativeLayout(activity);
  rlTitle.setBackgroundColor(0xffe6e9ec);
  int titleHeight = (int) (DESIGN_TITLE_HEIGHT * ratio);
  LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, titleHeight);
  llPage.addView(rlTitle, lp);
  initTitle(rlTitle, ratio);
  RelativeLayout rlBody = new RelativeLayout(activity);
  rlBody.setBackgroundColor(0xffffffff);
  lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
  llPage.addView(rlBody, lp);
  initBody(rlBody, ratio);
  LinearLayout llShadow = new LinearLayout(activity);
  llShadow.setOrientation(LinearLayout.VERTICAL);
  rlBody.addView(llShadow, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
  initShadow(llShadow, ratio);
  llBottom = new LinearLayout(activity);
  llBottom.setOrientation(LinearLayout.VERTICAL);
  lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
  llPage.addView(llBottom, lp);
  initBottom(llBottom, ratio);
}
origin: robolectric/robolectric

@Test
public void shouldSetTextAndTextColorWhileInflatingXmlLayout() throws Exception {
 Activity activity = activityController.get();
 activity.setContentView(R.layout.text_views);
 TextView black = (TextView) activity.findViewById(R.id.black_text_view);
 assertThat(black.getText().toString()).isEqualTo("Black Text");
 assertThat(black.getCurrentTextColor()).isEqualTo(0xff000000);
 TextView white = (TextView) activity.findViewById(R.id.white_text_view);
 assertThat(white.getText().toString()).isEqualTo("White Text");
 assertThat(white.getCurrentTextColor()).isEqualTo(activity.getResources().getColor(android.R.color.white));
 TextView grey = (TextView) activity.findViewById(R.id.grey_text_view);
 assertThat(grey.getText().toString()).isEqualTo("Grey Text");
 assertThat(grey.getCurrentTextColor()).isEqualTo(activity.getResources().getColor(R.color.grey42));
}
origin: robolectric/robolectric

@Before
public void setUp() {
 activity = Robolectric.setupActivity(Activity.class);
 view = new View(activity);
 activity.setContentView(view);
 listener = new TestListener();
}
origin: robolectric/robolectric

@Test public void setContentView_shouldReplaceOldContentView() throws Exception {
 View view1 = new View(application);
 view1.setId(R.id.burritos);
 View view2 = new View(application);
 view2.setId(R.id.button);
 Activity activity = buildActivity(Activity.class).create().get();
 activity.setContentView(view1);
 assertSame(view1, activity.findViewById(R.id.burritos));
 activity.setContentView(view2);
 assertNull(activity.findViewById(R.id.burritos));
 assertSame(view2, activity.findViewById(R.id.button));
}
origin: robolectric/robolectric

@Test // unclear what the correct behavior should be here...
public void shouldPopulateWindowDecorViewWithMergeLayoutContents() throws Exception {
 Activity activity = Robolectric.buildActivity(Activity.class).create().get();
 activity.setContentView(R.layout.toplevel_merge);
 View contentView = activity.findViewById(android.R.id.content);
 assertThat(((ViewGroup) contentView).getChildCount()).isEqualTo(2);
}
origin: robolectric/robolectric

@Test
public void shouldSetHintAndHintColorWhileInflatingXmlLayout() throws Exception {
 Activity activity = activityController.get();
 activity.setContentView(R.layout.text_views_hints);
 TextView black = (TextView) activity.findViewById(R.id.black_text_view_hint);
 assertThat(black.getHint().toString()).isEqualTo("Black Hint");
 assertThat(black.getCurrentHintTextColor()).isEqualTo(0xff000000);
 TextView white = (TextView) activity.findViewById(R.id.white_text_view_hint);
 assertThat(white.getHint().toString()).isEqualTo("White Hint");
 assertThat(white.getCurrentHintTextColor()).isEqualTo(activity.getResources().getColor(android.R.color.white));
 TextView grey = (TextView) activity.findViewById(R.id.grey_text_view_hint);
 assertThat(grey.getHint().toString()).isEqualTo("Grey Hint");
 assertThat(grey.getCurrentHintTextColor()).isEqualTo(activity.getResources().getColor(R.color.grey42));
}
origin: robolectric/robolectric

@Test
@Config(qualifiers = "w0dp")
public void testSetContentViewByItemResource() throws Exception {
 Activity activity = buildActivity(Activity.class).create().get();
 activity.setContentView(R.layout.main_layout);
 TextView tv1 = activity.findViewById(R.id.hello);
 TextView tv2 = activity.findViewById(R.id.world);
 assertNotNull(tv1);
 assertNull(tv2);
}
origin: robolectric/robolectric

@Test
@Config(qualifiers = "w820dp")
public void testSetContentViewByItemResourceWithW820dp() throws Exception {
 Activity activity = buildActivity(Activity.class).create().get();
 activity.setContentView(R.layout.main_layout);
 TextView tv1 = activity.findViewById(R.id.hello);
 TextView tv2 = activity.findViewById(R.id.world);
 assertNotNull(tv1);
 assertNotNull(tv2);
}
origin: robolectric/robolectric

@Test
public void shouldFindContentViewContainerWithChild() throws Exception {
 Activity activity = buildActivity(Activity.class).create().get();
 View contentView = new View(activity);
 activity.setContentView(contentView);
 FrameLayout contentViewContainer = (FrameLayout) activity.findViewById(android.R.id.content);
 assertThat(contentViewContainer.getChildAt(0)).isSameAs(contentView);
}
origin: robolectric/robolectric

@Test
public void usesDefaultGlobalVisibleRect() {
 final ActivityController<Activity> activityController = Robolectric.buildActivity(Activity.class);
 final Activity activity = activityController.get();
 activity.setContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
     ViewGroup.LayoutParams.MATCH_PARENT));
 activityController.setup();
 Rect globalVisibleRect = new Rect();
 assertThat(view.getGlobalVisibleRect(globalVisibleRect))
   .isTrue();
 assertThat(globalVisibleRect)
   .isEqualTo(new Rect(0, 25,
     DeviceConfig.DEFAULT_SCREEN_SIZE.width, DeviceConfig.DEFAULT_SCREEN_SIZE.height));
}
origin: bumptech/glide

@Before
public void setUp() {
 sdkVersion = Build.VERSION.SDK_INT;
 MockitoAnnotations.initMocks(this);
 activity = Robolectric.buildActivity(Activity.class).create().start().postCreate(null).resume();
 view = new View(activity.get());
 target = new TestViewTarget(view);
 attachStateTarget = new AttachStateTarget(view);
 LinearLayout linearLayout = new LinearLayout(activity.get());
 View expandView = new View(activity.get());
 LinearLayout.LayoutParams linearLayoutParams =
   new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, /*height=*/ 0);
 linearLayoutParams.weight = 1f;
 expandView.setLayoutParams(linearLayoutParams);
 linearLayout.addView(expandView);
 parent = new FrameLayout(activity.get());
 parent.addView(view);
 linearLayout.addView(parent);
 activity.get().setContentView(linearLayout);
}
origin: robolectric/robolectric

@Test
public void testInvalidOnClickAttribute() throws Exception {
 Activity activity = buildActivity(Activity.class).create().get();
 activity.setContentView(R.layout.with_invalid_onclick);
 Button button = activity.findViewById(R.id.invalid_onclick_button);
 IllegalStateException exception = null;
 try {
  button.performClick();
 } catch (IllegalStateException e) {
  exception = e;
 }
 assertNotNull(exception);
 assertThat(exception.getMessage())
   .named("The error message should contain the id name of the faulty button")
   .contains("invalid_onclick_button");
}
origin: robolectric/robolectric

@Test
public void shouldRetrieveTheCurrentViewFromViewId() {
 Activity activity = Robolectric.buildActivity(Activity.class).create().get();
 activity.setContentView(org.robolectric.R.layout.main);
 TabHost tabHost = new TabHost(activity);
 TabHost.TabSpec foo = tabHost.newTabSpec("Foo")
 .setContent(org.robolectric.R.id.title);
  tabHost.addTab(foo);
  tabHost.setCurrentTabByTag("Foo");
  TextView textView = (TextView) tabHost.getCurrentView();
 assertThat(textView.getText().toString()).isEqualTo("Main Layout");
}
origin: robolectric/robolectric

@Before
public void setUp() throws Exception {
 activityController = buildActivity(Activity.class);
 Activity activity = activityController.create().get();
 textView = new TextView(activity);
 activity.setContentView(textView);
 activityController.start().resume().visible();
}
android.appActivitysetContentView

Popular methods of Activity

  • onCreate
  • getWindow
  • finish
  • onDestroy
  • onResume
  • findViewById
  • startActivity
  • getResources
  • startActivityForResult
  • onPause
  • getSystemService
  • getWindowManager
  • getSystemService,
  • getWindowManager,
  • runOnUiThread,
  • isFinishing,
  • getString,
  • onStop,
  • getApplicationContext,
  • onStart,
  • onOptionsItemSelected,
  • getPackageName

Popular in Java

  • Finding current android device location
  • getApplicationContext (Context)
  • setRequestProperty (URLConnection)
  • compareTo (BigDecimal)
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • JComboBox (javax.swing)
  • JPanel (javax.swing)
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now