List of usage examples for android.view ViewGroup addView
@Override public void addView(View child, LayoutParams params)
From source file:com.gosuncn.core.util.view.StatusBarUtils.java
/** * DrawerLayout ???// w w w . j a v a 2s. co m * * @param activity ?activity * @param drawerLayout DrawerLayout * @param color ?? * @param statusBarAlpha ??? */ public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, int color, int statusBarAlpha) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); activity.getWindow().setStatusBarColor(Color.TRANSPARENT); } else { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } // ???? // statusBarView ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0); if (contentLayout.getChildCount() > 0 && contentLayout.getChildAt(0) instanceof StatusBarView) { contentLayout.getChildAt(0).setBackgroundColor(calculateStatusColor(color, statusBarAlpha)); } else { StatusBarView statusBarView = createStatusBarView(activity, color); contentLayout.addView(statusBarView, 0); } // ? LinearLayout ,padding top if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) { contentLayout.getChildAt(1).setPadding(contentLayout.getPaddingLeft(), getStatusBarHeight(activity) + contentLayout.getPaddingTop(), contentLayout.getPaddingRight(), contentLayout.getPaddingBottom()); } // ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1); drawerLayout.setFitsSystemWindows(false); contentLayout.setFitsSystemWindows(false); contentLayout.setClipToPadding(true); drawer.setFitsSystemWindows(false); addTranslucentView(activity, statusBarAlpha); }
From source file:de.grobox.liberario.utils.TransportrUtils.java
static public void addWalkingBox(Context context, ViewGroup lineLayout, int index) { ImageView v = (ImageView) LayoutInflater.from(context).inflate(R.layout.walking_box, lineLayout, false); // set margin, because setting in in xml does not work FlowLayout.LayoutParams llp = new FlowLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT); llp.setMargins(0, 5, 10, 5);/* ww w .j a v a2 s . c o m*/ v.setLayoutParams(llp); lineLayout.addView(v, index); }
From source file:com.fstrise.ilovekara.pagertab.ViewPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { container.addView(viewList.get(position), 0); return viewList.get(position); }
From source file:android.support.design.testutils.TestUtilsActions.java
/** * Replaces an existing {@link TabLayout} with a new one inflated from the specified * layout resource./*from w w w . j ava2 s . com*/ */ public static ViewAction replaceTabLayout(final @LayoutRes int tabLayoutResId) { return new ViewAction() { @Override public Matcher<View> getConstraints() { return isDisplayingAtLeast(90); } @Override public String getDescription() { return "Replace TabLayout"; } @Override public void perform(UiController uiController, View view) { uiController.loopMainThreadUntilIdle(); final ViewGroup viewGroup = (ViewGroup) view; final int childCount = viewGroup.getChildCount(); // Iterate over children and find TabLayout for (int i = 0; i < childCount; i++) { View child = viewGroup.getChildAt(i); if (child instanceof TabLayout) { // Remove the existing TabLayout viewGroup.removeView(child); // Create a new one final LayoutInflater layoutInflater = LayoutInflater.from(view.getContext()); final TabLayout newTabLayout = (TabLayout) layoutInflater.inflate(tabLayoutResId, viewGroup, false); // Make sure we're adding the new TabLayout at the same index viewGroup.addView(newTabLayout, i); break; } } uiController.loopMainThreadUntilIdle(); } }; }
From source file:com.firesoft.member.Adapter.Bee_PageAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { //?? container.addView(mListViews.get(position), 0);//? return mListViews.get(position); }
From source file:com.userhook.hookpoint.UHHookPointMessage.java
public void execute(final Activity activity) { final UHHookPoint hookPoint = this; final UHMessageView messageView = new UHMessageView(activity, this); activity.runOnUiThread(new Runnable() { @Override/*from w ww. j a va 2s . c o m*/ public void run() { // check for current activity so we have the top most activity in case another activity // has started since the hook points were loaded Activity currentActivity = UserHook.getActivityLifecycle().getCurrentActivity(); ViewGroup rootView = (ViewGroup) currentActivity.findViewById(android.R.id.content); rootView.addView(messageView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); messageView.showDialog(); UserHook.trackHookPointDisplay(hookPoint); } }); }
From source file:am.util.viewpager.adapter.ViewsPagerAdapter.java
@NonNull @Override// ww w . j a va 2s . c om public Object instantiateItem(@NonNull ViewGroup container, int position) { container.addView(mListViews.get(position), 0); return mListViews.get(position); }
From source file:com.commonsware.android.preso.slides.SlidesAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { ImageView page = new ImageView(ctxt); page.setImageResource(getPageResource(position)); container.addView(page, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return (page); }
From source file:com.dmbstream.android.activity.SearchResultsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Intent intent = getIntent();/*from w ww . j a v a 2 s . c o m*/ if (Intent.ACTION_SEARCH.equals(intent.getAction())) { query = intent.getStringExtra(SearchManager.QUERY); } else { query = intent.getStringExtra(Constants.EXTRA_QUERY_TERM); Log.d(TAG, "Query from other intent: " + query); } // After setting up variables so that they can be accessed in getApiUrl // which is called at the end of super.onCreate super.onCreate(savedInstanceState); // Push the search box into the layout group below the logo bar and above // the 'search results' title bar ViewGroup container = (ViewGroup) findViewById(R.id.TitleGroup); container.addView(ViewGroup.inflate(this, R.layout.partial_search_box, null), 0); searchBox = (EditText) findViewById(R.id.SearchText); searchBox.setText(query); searchBox.setOnKeyListener(this); ImageButton searchButton = (ImageButton) findViewById(R.id.search_go_button); searchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { AnalyticsUtil.trackEvent(SearchResultsActivity.this, "SearchResults", "Click", "Search", 0); search(); } }); inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (inputMethodManager != null) { inputMethodManager.hideSoftInputFromWindow(searchBox.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }
From source file:com.pax.view.ViewPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { try {/*from w w w . j a v a 2s . c o m*/ // View?? if (container != null) { container.removeAllViews(); container.addView(lists.get(position), 0); } } catch (Exception e) { e.printStackTrace(); } return lists.get(position); }