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 index) 

Source Link

Document

Adds a child view.

Usage

From source file:org.sufficientlysecure.keychain.ui.base.RecyclerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {

    final Context context = getContext();
    FrameLayout root = new FrameLayout(context);

    LinearLayout progressContainer = new LinearLayout(context);
    progressContainer.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    progressContainer.setOrientation(LinearLayout.VERTICAL);
    progressContainer.setGravity(Gravity.CENTER);
    progressContainer.setVisibility(View.GONE);

    ProgressBar progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);

    progressContainer.addView(progressBar, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(progressContainer, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    FrameLayout listContainer = new FrameLayout(context);
    listContainer.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView textView = new TextView(context);
    textView.setId(INTERNAL_EMPTY_VIEW_ID);
    textView.setGravity(Gravity.CENTER);

    listContainer.addView(textView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    RecyclerView listView = new RecyclerView(context);
    listView.setId(INTERNAL_LIST_VIEW_ID);

    int padding = FormattingUtils.dpToPx(context, 8);
    listView.setPadding(padding, 0, padding, 0);
    listView.setClipToPadding(false);/*  ww  w  .  j a  va2 s .  com*/

    listContainer.addView(listView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(listContainer, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}

From source file:com.origamilabs.library.app.StaggeredGridFragment.java

/**
 * Provide default implementation to return a simple list view. Subclasses
 * can override to replace with their own layout. If doing so, the returned
 * view hierarchy <em>must</em> have a StaggeredGridView whose id is
 * {@link android.R.id#list android.R.id.list} and can optionally have a
 * sibling view id {@link android.R.id#empty android.R.id.empty} that is to
 * be shown when the list is empty./* w  ww . j  a va2  s.c  o  m*/
 * 
 * <p>
 * If you are overriding this method with your own custom content, consider
 * including the standard layout {@link android.R.layout#list_content} in
 * your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment. In particular, this is currently the only way
 * to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Context context = getActivity();

    final FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    final LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    final FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    final TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    final StaggeredGridView lv = new StaggeredGridView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}

From source file:ch.arnab.simplelauncher.GridFragment.java

/**
 * Provide default implementation to return a simple grid view.  Subclasses
 * can override to replace with their own layout.  If doing so, the
 * returned view hierarchy <em>must</em> have a GridView whose id
 * is {@link android.R.id#list android.R.id.list} and can optionally
 * have a sibling view id {@link android.R.id#empty android.R.id.empty}
 * that is to be shown when the grid is empty.
 *
 * <p>If you are overriding this method with your own custom content,
 * consider including the standard layout {@link android.R.layout#list_content}
 * in your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment.  In particular, this is currently the only
 * way to have the built-in indeterminant progress state be shown.
 *//*from  w  w w .  j  a  va2s  .c o m*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();

    FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    GridView lv = new GridView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lv.setColumnWidth(convertDpToPixels(60, getActivity()));
    lv.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
    lv.setNumColumns(GridView.AUTO_FIT);
    lv.setHorizontalSpacing(convertDpToPixels(20, getActivity()));
    lv.setVerticalSpacing(convertDpToPixels(20, getActivity()));
    lv.setSmoothScrollbarEnabled(true);

    // disable overscroll
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        lv.setOverScrollMode(ListView.OVER_SCROLL_NEVER);
    }

    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}

From source file:com.ckdroid.ilauncher.ShowGridFragment.java

/**
 * Provide default implementation to return a simple grid view.  Subclasses
 * can override to replace with their own layout.  If doing so, the
 * returned view hierarchy <em>must</em> have a GridView whose id
 * is {@link android.R.id#list android.R.id.list} and can optionally
 * have a sibling view id {@link android.R.id#empty android.R.id.empty}
 * that is to be shown when the grid is empty.
 * <p/>//from   w  w  w . j a v  a 2 s . c om
 * <p>If you are overriding this method with your own custom content,
 * consider including the standard layout {@link android.R.layout#list_content}
 * in your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment.  In particular, this is currently the only
 * way to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();

    FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    GridView lv = new GridView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lv.setColumnWidth(convertDpToPixels(80, getActivity()));
    lv.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
    lv.setNumColumns(GridView.AUTO_FIT);
    lv.setNumColumns(4);
    lv.setHorizontalSpacing(convertDpToPixels(10, getActivity()));
    lv.setVerticalSpacing(convertDpToPixels(10, getActivity()));
    lv.setSmoothScrollbarEnabled(true);

    // disable overscroll
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        lv.setOverScrollMode(ListView.OVER_SCROLL_NEVER);
    }

    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}

From source file:com.imobile.mt8382hotkeydefine.GridFragment.java

/**
 * Provide default implementation to return a simple grid view.  Subclasses
 * can override to replace with their own layout.  If doing so, the
 * returned view hierarchy <em>must</em> have a GridView whose id
 * is {@link android.R.id#list android.R.id.list} and can optionally
 * have a sibling view id {@link android.R.id#empty android.R.id.empty}
 * that is to be shown when the grid is empty.
 *
 * <p>If you are overriding this method with your own custom content,
 * consider including the standard layout {@link android.R.layout#list_content}
 * in your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment.  In particular, this is currently the only
 * way to have the built-in indeterminant progress state be shown.
 *///  w  ww.jav  a  2s .  co m
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();

    FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);

    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    GridView lv = new GridView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lv.setColumnWidth(convertDpToPixels(60, getActivity()));
    lv.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
    lv.setNumColumns(GridView.AUTO_FIT);
    lv.setHorizontalSpacing(convertDpToPixels(20, getActivity()));
    lv.setVerticalSpacing(convertDpToPixels(20, getActivity()));
    lv.setSmoothScrollbarEnabled(true);

    // disable overscroll
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        lv.setOverScrollMode(ListView.OVER_SCROLL_NEVER);
    }

    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------
    /*
            root.setLayoutParams(new FrameLayout.LayoutParams(
        ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    */
    return root;
}

From source file:com.ckdroid.ilauncher.AllGridFragment.java

/**
 * Provide default implementation to return a simple grid view.  Subclasses
 * can override to replace with their own layout.  If doing so, the
 * returned view hierarchy <em>must</em> have a GridView whose id
 * is {@link android.R.id#list android.R.id.list} and can optionally
 * have a sibling view id {@link android.R.id#empty android.R.id.empty}
 * that is to be shown when the grid is empty.
 * <p/>/*w  w w.  ja v a2  s .co  m*/
 * <p>If you are overriding this method with your own custom content,
 * consider including the standard layout {@link android.R.layout#list_content}
 * in your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment.  In particular, this is currently the only
 * way to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();

    FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    GridView lv = new GridView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lv.setColumnWidth(convertDpToPixels(60, getActivity()));
    lv.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
    lv.setNumColumns(GridView.AUTO_FIT);
    lv.setHorizontalSpacing(convertDpToPixels(20, getActivity()));
    lv.setVerticalSpacing(convertDpToPixels(20, getActivity()));
    lv.setSmoothScrollbarEnabled(true);

    // disable overscroll
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        lv.setOverScrollMode(ListView.OVER_SCROLL_NEVER);
    }

    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    root.setPadding(24, 30, 24, 30);

    root.setBackgroundColor(getResources().getColor(R.color.bg_white));

    return root;
}

From source file:org.klnusbaum.udj.PullToRefresh.RefreshableListFragment.java

/**
 * Provide default implementation to return a simple list view. Subclasses
 * can override to replace with their own layout. If doing so, the returned
 * view hierarchy <em>must</em> have a ListView whose id is
 * {@link android.R.id#list android.R.id.list} and can optionally have a
 * sibling view id {@link android.R.id#empty android.R.id.empty} that is to
 * be shown when the list is empty.// ww  w.  ja  va2  s  .  c o m
 * 
 * <p>
 * If you are overriding this method with your own custom content, consider
 * including the standard layout {@link android.R.layout#list_content} in
 * your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment. In particular, this is currently the only way
 * to have the built-in indeterminant progress state be shown.
 */

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();

    FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    // ------------------------------------------------------------------

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    // ListView lv = new ListView(getActivity());
    PullToRefreshListView lv = (PullToRefreshListView) inflater.inflate(R.layout.pull_to_refresh_listview,
            null);
    pullToRefreshView = lv;
    lv.setOnRefreshListener(new OnRefreshListener() {
        @Override
        public void onRefresh() {
            // Do work to refresh the list here.
            doRefreshWork();
        }
    });
    // lv.setId(android.R.id.list);
    // lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    return root;
}

From source file:de.vanita5.twittnuker.fragment.support.BaseSupportListFragment.java

/**
 * Provide default implementation to return a simple list view. Subclasses
 * can override to replace with their own layout. If doing so, the returned
 * view hierarchy <em>must</em> have a ListView whose id is
 * {@link android.R.id#list android.R.id.list} and can optionally have a
 * sibling view id {@link android.R.id#empty android.R.id.empty} that is to
 * be shown when the list is empty.//w  ww.  j  a v a 2s. c o m
 *
 * <p>
 * If you are overriding this method with your own custom content, consider
 * including the standard layout {@link android.R.layout#list_content} in
 * your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment. In particular, this is currently the only way
 * to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Context context = getActivity();

    final FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    final LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    final FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    final TextView tv = new TextView(getActivity());
    tv.setTextAppearance(context, ThemeUtils.getTextAppearanceLarge(context));
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    final ListView lv = new ListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lv.setOnScrollListener(this);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}

From source file:android.support.v7.app.AlertController.java

private void setupCustomContent(ViewGroup customPanel) {
    final View customView;
    if (mView != null) {
        customView = mView;//w  ww  . j  a va  2s.  co m
    } else if (mViewLayoutResId != 0) {
        final LayoutInflater inflater = LayoutInflater.from(mContext);
        customView = inflater.inflate(mViewLayoutResId, customPanel, false);
    } else {
        customView = null;
    }

    final boolean hasCustomView = customView != null;
    if (!hasCustomView || !canTextInput(customView)) {
        mWindow.setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
                WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
    }

    if (hasCustomView) {
        final FrameLayout custom = (FrameLayout) mWindow.findViewById(R.id.custom);
        custom.addView(customView, new LayoutParams(MATCH_PARENT, MATCH_PARENT));

        if (mViewSpacingSpecified) {
            custom.setPadding(mViewSpacingLeft, mViewSpacingTop, mViewSpacingRight, mViewSpacingBottom);
        }

        if (mListView != null) {
            ((LinearLayout.LayoutParams) customPanel.getLayoutParams()).weight = 0;
        }
    } else {
        customPanel.setVisibility(View.GONE);
    }
}

From source file:at.wada811.app.fragment.ExpandableListFragment.java

/**
 * Provide default implementation to return a expandable list view. Subclasses
 * can override to replace with their own layout. If doing so, the returned
 * view hierarchy <em>must</em> have a ExpandableListView whose id
 * is {@link android.R.id#list android.R.id.list} and can optionally
 * have a sibling view id {@link android.R.id#empty android.R.id.empty} that is to be shown when
 * the list is empty./* w  w  w . j a  v  a2  s  .  c om*/
 * 
 * <p>
 * If you are overriding this method with your own custom content, consider including the
 * standard layout {@link android.R.layout#list_content} in your layout file, so that you
 * continue to retain all of the standard behavior of ExpandableListFragment. In particular,
 * this is currently the only way to have the built-in indeterminant progress state be shown.
 * 
 * @param inflater The LayoutInflater object that can be used to inflate any views in the
 *        fragment,
 * @param container If non-null, this is the parent view that the fragment's UI should be
 *        attached to. The fragment should not add the view itself, but this can be used to
 *        generate the LayoutParams of the view.
 * @param savedInstanceState If non-null, this fragment is being re-constructed from a previous
 *        saved state as given here.
 * @return Return the View for the fragment's UI, or null.
 */
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Context context = getActivity();

    final FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    final LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    final FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    final TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    final ExpandableListView lv = new ExpandableListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}