Example usage for android.widget FrameLayout addView

List of usage examples for android.widget FrameLayout addView

Introduction

In this page you can find the example usage for android.widget FrameLayout addView.

Prototype

public void addView(View child, int width, int height) 

Source Link

Document

Adds a child view with this ViewGroup's default layout parameters and the specified width and height.

Usage

From source file:com.nextgis.woody.fragment.MapFragment.java

private void addMap() {
    if (mMapRelativeLayout != null) {
        FrameLayout map = (FrameLayout) mMapRelativeLayout.findViewById(R.id.mapfl);
        map.addView(mMap, 0, new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
                RelativeLayout.LayoutParams.MATCH_PARENT));
    }//from  w w w.j  av a  2s  .c om
}

From source file:com.qianjiang.framework.widget.pulltorefresh.PullToRefreshListView.java

@Override
protected final ListView createRefreshableView(Context context, AttributeSet attrs) {
    ListView lv = new InternalListView(context, attrs);
    // Get Styles from attrs
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PullToRefresh);

    // Create Loading Views ready for use later
    FrameLayout frame = new FrameLayout(context);
    mHeaderLoadingView = new HeaderLoadingLayout(context, Mode.PULL_DOWN_TO_REFRESH, a);
    frame.addView(mHeaderLoadingView, android.view.ViewGroup.LayoutParams.FILL_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
    mHeaderLoadingView.setVisibility(View.GONE);
    lv.addHeaderView(frame, null, false);

    mLvFooterLoadingFrame = new FrameLayout(context);
    mFooterLoadingView = new FooterLoadingLayout(context, Mode.PULL_UP_TO_REFRESH, a);
    mLvFooterLoadingFrame.addView(mFooterLoadingView, android.view.ViewGroup.LayoutParams.FILL_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
    mFooterLoadingView.setVisibility(View.GONE);

    a.recycle();/*from   w  w  w . j  a  v  a  2  s.com*/

    // Set it to this so it can be used in ListActivity/ListFragment
    lv.setId(android.R.id.list);
    return lv;
}

From source file:gov.sfmta.sfpark.MainScreenActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    MYLOG("onCreate");

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);/*from w  ww. j  av  a 2s  .  c o m*/

    // Set up ActionBar
    ActionBar ab = getSupportActionBar();
    ab.setDisplayShowTitleEnabled(false);
    ab.setIcon(R.drawable.logo_header);
    ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    ab.addTab(ab.newTab().setText("Price").setTabListener(new TabListener()));
    ab.addTab(ab.newTab().setText("Availability").setTabListener(new TabListener()));

    // Dropdown navigation
    final String[] dropdownValues = getResources().getStringArray(R.array.dropdown);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(ab.getThemedContext(),
            R.layout.sherlock_spinner_item, android.R.id.text1, dropdownValues);
    adapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
    ab.setListNavigationCallbacks(adapter, this);

    if (SFparkActivity.DEBUG) {
        debugText = (TextView) findViewById(R.id.debugText);
        debugText.setText("Debug String");
        debugText.setVisibility(View.VISIBLE);
    }

    legendlabel = (TextView) findViewById(R.id.legendText);
    legendImage = (ImageView) findViewById(R.id.keyImage);

    // DoubleTapMapView... is a mapview that you can double-tap. :-/
    mapView = new DoubleTapMapView(this);
    FrameLayout fl = (FrameLayout) findViewById(R.id.mapframe);
    fl.addView(mapView, 0, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    mapView.setBuiltInZoomControls(true);
    mc = mapView.getController();

    // Creating and initializing Map
    GeoPoint p = getPoint(INITIAL_LATITUDE, INITIAL_LONGITUDE);

    mc.setCenter(p);
    mc.setZoom(14);

    startLocation();

    showPrice = true;

    enablePanToMe();
    reset();
}

From source file:com.example.guxiuzhong.pagerslidingtab_lib.PagerSlidingTabStrip.java

private void addTab(final int position, View tab, View tab2) {

    tab.setPadding(tabPadding, 0, tabPadding, 0);
    tab2.setPadding(tabPadding, 0, tabPadding, 0);

    FrameLayout framelayout = new FrameLayout(context);
    framelayout.addView(tab, 0, matchparentTabLayoutParams);
    framelayout.addView(tab2, 1, matchparentTabLayoutParams);
    tabsContainer.addView(framelayout, position,
            shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);

    framelayout.setOnClickListener(new OnClickListener() {
        @Override/*from   www .  j a v a2  s  . c o m*/
        public void onClick(View v) {
            //?
            pager.setCurrentItem(position, true);
            currentPosition = position;
            scrollToChild(position, 0);//HorizontalScrollView
            invalidate();//?
        }
    });

    Map<String, View> map = new HashMap<>();

    ViewHelper.setAlpha(tab, 1);
    map.put("normal", tab);

    ViewHelper.setAlpha(tab2, 0);
    map.put("selected", tab2);

    tabViews.add(position, map);
}

From source file:com.alexive.graphicalutils.fragments.RecyclerViewFragment.java

/**
 * Sets a view to be displayed when the list is empty with optional LayoutParams.
 * @param view Displayed when the list is empty.
 * @param params Information about how view's layout in the countainer.
 *//*from  www .j av a  2s. c om*/
public void setEmptyView(View view, FrameLayout.LayoutParams params) {
    emptyView = view;
    isEmptyViewEmptyText = true;
    FrameLayout frameLayout = (FrameLayout) getView();
    if (frameLayout == null)
        return;
    //In order to avoid having more than one emptyViews added to the layout
    if (frameLayout.getChildCount() > 2)
        frameLayout.removeViewAt(2);
    if (this.emptyText != null)
        frameLayout.findViewById(android.R.id.text1).setVisibility(View.GONE);
    if (params == null) {
        params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        params.gravity = Gravity.CENTER;
    }

    frameLayout.addView(view, 1, params);
    this.emptyViewAddedToLayout = true;
    actuallySetEmptyView();
}

From source file:com.goodhustle.ouyaunitybridge.OuyaUnityActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    OuyaController.init(this);

    // Initialize ouyaFacade
    ouyaFacade = OuyaFacade.getInstance();
    ouyaFacade.init(this, DEVELOPER_ID);
    userManager = UserManager.getInstance(this);
    playerStates = new ControllerState[OuyaController.MAX_CONTROLLERS];
    for (int i = 0; i < OuyaController.MAX_CONTROLLERS; i++) {
        playerStates[i] = new ControllerState();
    }/*from w w  w  .  j a  va 2  s . c o  m*/

    // Create the UnityPlayer
    mUnityPlayer = new UnityPlayer(this);
    int glesMode = mUnityPlayer.getSettings().getInt("gles_mode", 1);
    boolean trueColor8888 = false;
    mUnityPlayer.init(glesMode, trueColor8888);
    setContentView(R.layout.main);

    // Add the Unity view
    FrameLayout layout = (FrameLayout) findViewById(R.id.unityLayout);
    LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    layout.addView(mUnityPlayer.getView(), 0, lp);

    // Set the focus
    RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.mainLayout);
    mainLayout.setFocusableInTouchMode(true);

    // Attempt to restore the product and receipt list from the savedInstanceState Bundle
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(PRODUCTS_INSTANCE_STATE_KEY)) {
            Parcelable[] products = savedInstanceState.getParcelableArray(PRODUCTS_INSTANCE_STATE_KEY);
            mProductList = new ArrayList<Product>(products.length);
            for (Parcelable product : products) {
                mProductList.add((Product) product);
            }
            addProducts();
        }
        if (savedInstanceState.containsKey(RECEIPTS_INSTANCE_STATE_KEY)) {
            Parcelable[] receipts = savedInstanceState.getParcelableArray(RECEIPTS_INSTANCE_STATE_KEY);
            mReceiptList = new ArrayList<Receipt>(receipts.length);
            for (Parcelable receipt : receipts) {
                mReceiptList.add((Receipt) receipt);
            }
            addReceipts();
        }
    }

    // Request the product list if it could not be restored from the savedInstanceState Bundle
    if (mProductList == null) {
        requestProducts();
    }

    // Create a PublicKey object from the key data downloaded from the developer portal.
    try {
        X509EncodedKeySpec keySpec = new X509EncodedKeySpec(APPLICATION_KEY);
        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        mPublicKey = keyFactory.generatePublic(keySpec);
    } catch (Exception e) {
        Log.e(LOG_TAG, "Unable to create encryption key", e);
    }
}

From source file:com.mishiranu.dashchan.ui.navigator.DrawerForm.java

private View makeSimpleDivider() {
    float density = ResourceUtils.obtainDensity(context);
    if (C.API_LOLLIPOP) {
        FrameLayout frameLayout = new FrameLayout(context);
        View view = new View(context);
        view.setBackgroundResource(ResourceUtils.getResourceId(context, android.R.attr.listDivider, 0));
        frameLayout.addView(view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        frameLayout.setPadding(0, (int) (8f * density), 0, (int) (8f * density));
        return frameLayout;
    } else {/*from  w  w  w.j  a v a  2  s.  co m*/
        View view = new View(context);
        int[] attrs = { android.R.attr.listSeparatorTextViewStyle };
        TypedArray typedArray = context.obtainStyledAttributes(attrs);
        int style = typedArray.getResourceId(0, 0);
        typedArray.recycle();
        if (style != 0) {
            typedArray = context.obtainStyledAttributes(style, new int[] { android.R.attr.background });
            Drawable drawable = typedArray.getDrawable(0);
            typedArray.recycle();
            if (drawable != null) {
                view.setBackgroundColor(GraphicsUtils.getDrawableColor(context, drawable, Gravity.BOTTOM));
            }
        }
        view.setMinimumHeight((int) (2f * density));
        return view;
    }
}