Example usage for android.widget FrameLayout setId

List of usage examples for android.widget FrameLayout setId

Introduction

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

Prototype

public void setId(@IdRes int id) 

Source Link

Document

Sets the identifier for this view.

Usage

From source file:de.memorian.ps4trophaen.util.ExpandableListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        lastExpandedPosition = savedInstanceState.getInt(LAST_EXP_POS, -1);
    }/*from  w  ww .j a v  a 2s . c  om*/
    FrameLayout root = new FrameLayout(getActivity());

    FrameLayout lframe = new FrameLayout(getActivity());
    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));

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

    ListView.LayoutParams lp = new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    root.setLayoutParams(lp);

    return root;
}

From source file:com.example.almin.widget.MyFragmentTabHost.java

private void ensureHierarchy(Context context) {
    // If owner hasn't made its own view hierarchy, then as a convenience  
    // we will construct a standard one here.  
    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);/*from  w ww. j  a  v a  2  s.  co m*/
        tw.setOrientation(TabWidget.HORIZONTAL);
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1));
    }
}

From source file:cn.bproject.neteasynews.widget.FragmentTabHost.java

private void ensureHierarchy(Context context) {
    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);//w w  w.  ja v  a2 s . c  o  m
        tw.setOrientation(TabWidget.HORIZONTAL);
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1));
    }
}

From source file:com.summer.framework.ui.widget.FragmentTabHost.java

private void ensureHierarchy(Context context) {
    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);/*from   w w w  .  ja  v  a2  s  .c o m*/
        tw.setOrientation(LinearLayout.HORIZONTAL);
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));
        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));
        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, 0, 1));
    }
}

From source file:libraries.stackoverflow.ExpandableListFragment.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./*from  ww  w  .  ja v  a  2 s.  c o m*/
 * <p/>
 * <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.
 */
@SuppressWarnings("deprecation")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FrameLayout root = new FrameLayout(getActivity());

    FrameLayout lframe = new FrameLayout(getActivity());
    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));

    ExpandableListView lv = new ExpandableListView(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));

    ListView.LayoutParams lp = new ListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT);
    root.setLayoutParams(lp);

    return root;
}

From source file:com.anlddev.customwidget.widget.AFragmentTabHost.java

private void ensureHierarchy(Context context) {
    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);/* w w w.  ja va2s.  co m*/
        tw.setOrientation(TabWidget.HORIZONTAL);
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1));
    }
}

From source file:com.example.android.adaptertransition.AdapterTransitionFragment.java

/**
 * Copy all the visible views in the mAbsListView into a new FrameLayout and return it.
 *
 * @return a FrameLayout with all the visible views inside.
 *///from w  w w  .  ja  v a  2s .  c om
private FrameLayout copyVisibleViews() {
    // This is the FrameLayout we return afterwards.
    FrameLayout layout = new FrameLayout(getActivity());
    // The transition framework requires to set ID for all views to be animated.
    layout.setId(ROOT_ID);
    // We only copy visible views.
    int first = mAbsListView.getFirstVisiblePosition();
    int index = 0;
    while (true) {
        // This is one of the views that we copy. Note that the argument for getChildAt is a
        // zero-oriented index, and it doesn't usually match with its position in the list.
        View source = mAbsListView.getChildAt(index);
        if (null == source) {
            break;
        }
        // This is the copy of the original view.
        View destination = mAdapter.getView(first + index, null, layout);
        assert destination != null;
        destination.setId(ROOT_ID + first + index);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(source.getWidth(), source.getHeight());
        params.leftMargin = (int) source.getX();
        params.topMargin = (int) source.getY();
        layout.addView(destination, params);
        ++index;
    }
    return layout;
}

From source file:com.example.kent_zheng.sdk_adaptertransition.AdapterTransitionFragment.java

/**
 * Copy all the visible views in the mAbsListView into a new FrameLayout and return it.
 *
 * @return a FrameLayout with all the visible views inside.
 *//*from   w w w .  ja va 2 s .c  om*/
private FrameLayout copyVisibleViews() {
    // This is the FrameLayout we return afterwards.
    FrameLayout layout = new FrameLayout(getActivity());
    // The transition framework requires to set ID for all views to be animated.
    layout.setId(ROOT_ID);
    // We only copy visible views.
    int first = mAbsListView.getFirstVisiblePosition();
    int index = 0;
    while (true) {
        // This is one of the views that we copy. Note that the argument for getChildAt is a
        // zero-oriented index, and it doesn't usually match with its position in the list.
        View source = mAbsListView.getChildAt(index);

        if (null == source) { //
            break;
        }

        // This is the copy of the original view.
        View destination = mAdapter.getView(first + index, null, layout);
        assert destination != null;
        destination.setId(ROOT_ID + first + index);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(source.getWidth(), source.getHeight());
        params.leftMargin = (int) source.getX();
        params.topMargin = (int) source.getY();
        layout.addView(destination, params);
        ++index;
    }
    return layout;
}

From source file:com.ustc.dystu.dandelion.fragment.BaseFragmentTabHost.java

private void initFragmentTabHost(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0);
    mContainerId = a.getResourceId(0, 0);
    a.recycle();/*from w w w  . ja  v  a 2  s  .  c o  m*/

    super.setOnTabChangedListener(this);

    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);
        tw.setOrientation(TabWidget.HORIZONTAL);
        tw.setDividerDrawable(null);//?ab?
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, 0, 1));
    }
}

From source file:cn.thinkjoy.startup.widget.FragmentTabHost.java

private void ensureHierarchy(Context context) {
    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);

        addView(ll, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);/*ww w  .j av a 2 s  .c o m*/

        tw.setOrientation(LinearLayout.HORIZONTAL);

        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));
        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);

        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));
        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1));
    }
}