Example usage for android.widget FrameLayout FrameLayout

List of usage examples for android.widget FrameLayout FrameLayout

Introduction

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

Prototype

public FrameLayout(@NonNull Context context) 

Source Link

Usage

From source file:com.github.jobs.ui.activity.BaseActivity.java

/**
 * Helper method that allows to initialize and add a fragment to activities that usually have
 * just one single fragment. Fragment is added using its class.getName() as tag.
 *
 * @param containerId resource id of the fragment container (must be created through android
 * resources)/*  w ww  .  ja  v a 2  s  . co m*/
 * @param fragmentClass the class of the fragment to setup
 * @param args bundle with the arguments to pass to the fragment
 */
void setupBaseFragment(int containerId, Class<? extends Fragment> fragmentClass, Bundle args) {
    if (mSetContentViewAlreadyCalled) {
        View view = findViewById(containerId);
        if (!(view instanceof ViewGroup)) {
            throw new IllegalStateException(
                    "Since you already called setContentView, it must has a ViewGroup whose id is 'containerId'");
        }
    } else {
        FrameLayout container = new FrameLayout(this);
        container.setId(containerId);
        setContentView(container);
    }

    // let's check whether fragment is already added
    Fragment fragment = findFragment(fragmentClass);
    if (fragment == null) {
        // if not, let's create it and add it
        fragment = Fragment.instantiate(this, fragmentClass.getName(), args);

        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.add(containerId, fragment, fragmentClass.getSimpleName());
        ft.commit();
    }
}

From source file:org.telegram.ui.ArchivedStickersActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    if (currentType == StickersQuery.TYPE_IMAGE) {
        actionBar.setTitle(LocaleController.getString("ArchivedStickers", R.string.ArchivedStickers));
    } else {/*from   w ww.  j  a va2s  . c  o m*/
        actionBar.setTitle(LocaleController.getString("ArchivedMasks", R.string.ArchivedMasks));
    }
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    listAdapter = new ListAdapter(context);

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background));

    emptyView = new EmptyTextProgressView(context);
    if (currentType == StickersQuery.TYPE_IMAGE) {
        emptyView.setText(LocaleController.getString("ArchivedStickersEmpty", R.string.ArchivedStickersEmpty));
    } else {
        emptyView.setText(LocaleController.getString("ArchivedMasksEmpty", R.string.ArchivedMasksEmpty));
    }
    frameLayout.addView(emptyView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    if (loadingStickers) {
        emptyView.showProgress();
    } else {
        emptyView.showTextView();
    }

    RecyclerListView listView = new RecyclerListView(context);
    listView.setFocusable(true);
    listView.setEmptyView(emptyView);
    listView.setLayoutManager(
            layoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));

    frameLayout.addView(listView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    listView.setAdapter(listAdapter);
    listView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() {
        @Override
        public void onItemClick(final View view, int position) {
            if (position >= stickersStartRow && position < stickersEndRow && getParentActivity() != null) {
                final TLRPC.StickerSetCovered stickerSet = sets.get(position);
                TLRPC.InputStickerSet inputStickerSet;
                if (stickerSet.set.id != 0) {
                    inputStickerSet = new TLRPC.TL_inputStickerSetID();
                    inputStickerSet.id = stickerSet.set.id;
                } else {
                    inputStickerSet = new TLRPC.TL_inputStickerSetShortName();
                    inputStickerSet.short_name = stickerSet.set.short_name;
                }
                inputStickerSet.access_hash = stickerSet.set.access_hash;
                StickersAlert stickersAlert = new StickersAlert(getParentActivity(),
                        ArchivedStickersActivity.this, inputStickerSet, null, null);
                stickersAlert.setInstallDelegate(new StickersAlert.StickersAlertInstallDelegate() {
                    @Override
                    public void onStickerSetInstalled() {
                        ArchivedStickerSetCell cell = (ArchivedStickerSetCell) view;
                        cell.setChecked(true);
                    }

                    @Override
                    public void onStickerSetUninstalled() {
                        ArchivedStickerSetCell cell = (ArchivedStickerSetCell) view;
                        cell.setChecked(false);
                    }
                });
                showDialog(stickersAlert);
            }
        }
    });
    listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            if (!loadingStickers && !endReached
                    && layoutManager.findLastVisibleItemPosition() > stickersLoadingRow - 2) {
                getStickers();
            }
        }
    });

    return fragmentView;
}

From source file:com.abhi.barcode.frag.libv2.BarcodeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FrameLayout frameLayout = new FrameLayout(getActivity());
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);//from ww w.  j a  va2 s. com
    frameLayout.setLayoutParams(layoutParams);
    surfaceView = new SurfaceView(getActivity());
    surfaceView.setLayoutParams(layoutParams);
    viewfinderView = new ViewfinderView(getActivity());
    viewfinderView.setLayoutParams(layoutParams);
    frameLayout.addView(surfaceView);
    frameLayout.addView(viewfinderView);
    View v = frameLayout;
    inactivityTimer = new InactivityTimer(this.getActivity());
    ambientLightManager = new AmbientLightManager(this.getActivity());
    return v;
}

From source file:org.yasik.android.app.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 list is empty.//from  w  ww . j a v a2s. 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
 * GridFragment. 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);
    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.achep.header2actionbar.HeaderFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Activity activity = getActivity();
    assert activity != null;
    mFrameLayout = new FrameLayout(activity);

    mHeader = onCreateHeaderView(inflater, mFrameLayout);
    mHeaderHeader = mHeader.findViewById(android.R.id.title);
    mHeaderBackground = mHeader.findViewById(android.R.id.background);
    assert mHeader.getLayoutParams() != null;
    mHeaderHeight = mHeader.getLayoutParams().height;

    mFakeHeader = new Space(activity);
    mFakeHeader.setLayoutParams(new ListView.LayoutParams(0, mHeaderHeight));

    View content = onCreateContentView(inflater, mFrameLayout);
    if (content instanceof ListView) {
        isListViewEmpty = true;/* ww w  .  j a v a  2 s .c om*/

        final ListView listView = (ListView) content;
        listView.addHeaderView(mFakeHeader);
        onSetAdapter();
        listView.setOnScrollListener(new AbsListView.OnScrollListener() {

            @Override
            public void onScrollStateChanged(AbsListView absListView, int scrollState) {
                if (mOnScrollListener != null) {
                    mOnScrollListener.onScrollStateChanged(absListView, scrollState);
                }
            }

            @Override
            public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
                if (mOnScrollListener != null) {
                    mOnScrollListener.onScroll(absListView, firstVisibleItem, visibleItemCount, totalItemCount);
                }

                isListViewEmpty = listView.getAdapter() == null;
                if (isListViewEmpty) {
                    scrollHeaderTo(0);
                } else {
                    final View child = absListView.getChildAt(0);
                    assert child != null;
                    scrollHeaderTo(child == mFakeHeader ? child.getTop() : -mHeaderHeight);
                    //                        Log.v("header height",String.format("mHeaderHeight:%s",mHeaderHeight));
                }
            }
        });
    } else if (content instanceof GridView) {
        isListViewEmpty = true;

        final GridView grid = (GridView) content;
        //isListViewEmpty = grid.getAdapter() == null;
        //            grid.addHeaderView(mFakeHeader);

        // Merge fake header view and content view.
        final LinearLayout view = new LinearLayout(activity);
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        view.setOrientation(LinearLayout.VERTICAL);
        view.addView(mFakeHeader);
        view.addView(grid);

        grid.setOnScrollListener(new AbsListView.OnScrollListener() {

            private ListViewScrollTracker mScrollTracker;;

            @Override
            public void onScrollStateChanged(AbsListView absListView, int scrollState) {
                if (mOnScrollListener != null) {
                    mOnScrollListener.onScrollStateChanged(absListView, scrollState);
                }
            }

            public int getGridScrollY(GridView grid) {

                Method privateStringMethod = null;
                Integer scrollOffset = null;
                Integer scrollExtent = null;
                Integer scrollRange = null;
                try {
                    privateStringMethod = GridView.class.getDeclaredMethod("computeVerticalScrollOffset", null);
                    privateStringMethod.setAccessible(true);
                    scrollOffset = (Integer) privateStringMethod.invoke(grid, null);

                    privateStringMethod = GridView.class.getDeclaredMethod("computeVerticalScrollExtent", null);
                    privateStringMethod.setAccessible(true);
                    scrollExtent = (Integer) privateStringMethod.invoke(grid, null);

                    privateStringMethod = GridView.class.getDeclaredMethod("computeVerticalScrollRange", null);
                    privateStringMethod.setAccessible(true);
                    scrollRange = (Integer) privateStringMethod.invoke(grid, null);
                } catch (NoSuchMethodException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalArgumentException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (InvocationTargetException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return scrollRange;//scrollExtent*scrollOffset;  

            }

            @Override
            public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
                if (mScrollTracker == null)
                    mScrollTracker = new ListViewScrollTracker(absListView);
                mScrollPosition = mScrollTracker.calculateIncrementalOffset(firstVisibleItem, visibleItemCount);
                Log.v("header", "scrollPosition:" + mScrollPosition);
                if (mOnScrollListener != null) {
                    mOnScrollListener.onScroll(absListView, firstVisibleItem, visibleItemCount, totalItemCount);
                }

                final View child = absListView.getChildAt(0);
                if (child != null) {
                    int gridScrollY = mScrollPosition;//getGridScrollY((GridView) absListView);
                    scrollHeaderTo(-gridScrollY);

                    //change the size of the fake header on scrolling                        
                    int currentHeight = mFakeHeader.getLayoutParams().height;
                    Integer fakeHeaderHeight = (int) (mHeaderHeight - (gridScrollY * 2));
                    mFakeHeader.setLayoutParams(new android.widget.LinearLayout.LayoutParams(
                            mFakeHeader.getWidth(), fakeHeaderHeight));
                    //                  setViewTranslationY(mFrameLayout, -1*(gridScrollY));
                } else
                    scrollHeaderTo(0);
            }
        });
        content = view;
    } else {

        // Merge fake header view and content view.
        final LinearLayout view = new LinearLayout(activity);
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        view.setOrientation(LinearLayout.VERTICAL);
        view.addView(mFakeHeader);
        view.addView(content);

        // Put merged content to ScrollView
        final NotifyingScrollView scrollView = new NotifyingScrollView(activity);
        scrollView.addView(view);
        scrollView.setOnScrollChangedListener(new NotifyingScrollView.OnScrollChangedListener() {
            @Override
            public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) {
                scrollHeaderTo(-t);
            }
        });
        content = scrollView;
    }

    mFrameLayout.addView(content);
    mFrameLayout.addView(mHeader);

    // Content overlay view always shows at the top of content.
    if ((mContentOverlay = onCreateContentOverlayView(inflater, mFrameLayout)) != null) {
        mFrameLayout.addView(mContentOverlay, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
    }

    // Post initial scroll
    mFrameLayout.post(new Runnable() {
        @Override
        public void run() {
            scrollHeaderTo(0, true);
        }
    });

    return mFrameLayout;
}

From source file:com.flexible.flexibleadapter.helpers.StickyHeaderHelper.java

private FrameLayout createContainer(int width, int height) {
    FrameLayout frameLayout = new FrameLayout(mRecyclerView.getContext());
    frameLayout.setLayoutParams(new ViewGroup.LayoutParams(width, height));
    return frameLayout;
}

From source file:de.vanita5.twittnuker.fragment.support.BasePullToRefreshListFragment.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  .  j  ava2 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(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 RefreshNowListView lv = new RefreshNowListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setOverScrollMode(View.OVER_SCROLL_NEVER);
    lv.setDrawSelectorOnTop(false);
    lv.setOnRefreshListener(this);
    lv.setConfig(ThemeUtils.buildRefreshNowConfig(context));
    lv.setOnTouchListener(this);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    final RefreshNowProgressIndicator indicator = new RefreshNowProgressIndicator(context);
    indicator.setConfig(ThemeUtils.buildRefreshIndicatorConfig(context));
    final int indicatorHeight = Math.round(3 * getResources().getDisplayMetrics().density);
    lframe.addView(indicator,
            new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, indicatorHeight, Gravity.TOP));

    lv.setRefreshIndicatorView(indicator);

    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.heneryh.aquanotes.ui.SearchActivity.java

/**
 * Build and add "sessions" tab.//  w ww  .  j a  v  a2  s . co m
 */
private void setupSessionsTab() {
    // TODO: this is very inefficient and messy, clean it up
    FrameLayout fragmentContainer = new FrameLayout(this);
    fragmentContainer.setId(R.id.fragment_probes);
    fragmentContainer.setLayoutParams(
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    ((ViewGroup) findViewById(android.R.id.tabcontent)).addView(fragmentContainer);

    final FragmentManager fm = getSupportFragmentManager();
    mSessionsFragment = (DbMaintProbesFragment) fm.findFragmentByTag("sessions");
    if (mSessionsFragment == null) {
        mSessionsFragment = new DbMaintProbesFragment();
        mSessionsFragment.setArguments(getSessionsFragmentArguments());
        fm.beginTransaction().add(R.id.fragment_probes, mSessionsFragment, "sessions").commit();
    } else {
        mSessionsFragment.reloadFromArguments(getSessionsFragmentArguments());
    }

    // Sessions content comes from reused activity
    mTabHost.addTab(mTabHost.newTabSpec(TAG_SESSIONS).setIndicator(buildIndicator(R.string.db_maint_probes))
            .setContent(R.id.fragment_probes));
}

From source file:hotstu.github.bdzviewer.ui.CustomListFragment.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 w w .ja v  a 2  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());
    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:org.telegram.ui.BlockedUsersActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("BlockedUsers", R.string.BlockedUsers));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override/* w  w w.  j  a  v a2 s  .  co  m*/
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == block_user) {
                Bundle args = new Bundle();
                args.putBoolean("onlyUsers", true);
                args.putBoolean("destroyAfterSelect", true);
                args.putBoolean("returnAsResult", true);
                ContactsActivity fragment = new ContactsActivity(args);
                fragment.setDelegate(BlockedUsersActivity.this);
                presentFragment(fragment);
            }
        }
    });

    ActionBarMenu menu = actionBar.createMenu();
    menu.addItem(block_user, R.drawable.plus);

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;

    emptyTextView = new TextView(context);
    emptyTextView.setTextColor(ContextCompat.getColor(context, R.color.disabled_text));
    emptyTextView.setTextSize(20);
    emptyTextView.setGravity(Gravity.CENTER);
    emptyTextView.setVisibility(View.INVISIBLE);
    emptyTextView.setText(LocaleController.getString("NoBlocked", R.string.NoBlocked));
    frameLayout.addView(emptyTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
    emptyTextView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    progressView = new FrameLayout(context);
    frameLayout.addView(progressView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    ProgressBar progressBar = new ProgressBar(context);
    progressView.addView(progressBar,
            LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));

    listView = new ListView(context);
    listView.setEmptyView(emptyTextView);
    listView.setVerticalScrollBarEnabled(false);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setAdapter(listViewAdapter = new ListAdapter(context));
    listView.setVerticalScrollbarPosition(
            LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
    frameLayout.addView(listView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (i < MessagesController.getInstance().blockedUsers.size()) {
                Bundle args = new Bundle();
                args.putInt("user_id", MessagesController.getInstance().blockedUsers.get(i));
                presentFragment(new ProfileActivity(args));
            }
        }
    });

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (i < 0 || i >= MessagesController.getInstance().blockedUsers.size()
                    || getParentActivity() == null) {
                return true;
            }
            selectedUserId = MessagesController.getInstance().blockedUsers.get(i);

            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            CharSequence[] items = new CharSequence[] {
                    LocaleController.getString("Unblock", R.string.Unblock) };
            builder.setItems(items, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    if (i == 0) {
                        MessagesController.getInstance().unblockUser(selectedUserId);
                    }
                }
            });
            showDialog(builder.create());

            return true;
        }
    });

    if (MessagesController.getInstance().loadingBlockedUsers) {
        progressView.setVisibility(View.VISIBLE);
        emptyTextView.setVisibility(View.GONE);
        listView.setEmptyView(null);
    } else {
        progressView.setVisibility(View.GONE);
        listView.setEmptyView(emptyTextView);
    }
    return fragmentView;
}