Java Code Examples for android.support.v7.widget.RecyclerView#setId()

The following examples show how to use android.support.v7.widget.RecyclerView#setId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecyclerFragment.java    From AndroidDigIn with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final Context context = getContext();

    FrameLayout root = new FrameLayout(context);

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

    mRecyclerContainer = new FrameLayout(context);
    mRecyclerContainer.setId(R.id.recycler_container_id);

    mStandardEmptyView = new TextView(context);
    mStandardEmptyView.setId(R.id.recycler_empty_id);
    mStandardEmptyView.setGravity(Gravity.CENTER);
    mStandardEmptyView.setVisibility(View.GONE);
    mRecyclerContainer.addView(mStandardEmptyView, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    mRecyclerView = new RecyclerView(context);
    mRecyclerView.setId(R.id.recycler);
    mRecyclerContainer.addView(mRecyclerView, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(mRecyclerContainer, 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;
}
 
Example 2
Source File: PopMenuLayout.java    From PopMenuLayout with MIT License 5 votes vote down vote up
private void init(Context context, AttributeSet attrs, int defStyleAttr){
    initAttrs(context, attrs, defStyleAttr);
    mMenuShow = new boolean[SUPPORT_MENU_LEVEL];
    for (int i = 0; i < SUPPORT_MENU_LEVEL; i++) {
        mMenuShow[i] = i == 0;
    }
    mContext = context;
    mMenus = new ArrayList<MenuBean>();
    m1LevelMenuAdapter = new MenuAdapter(mContext, mMenus, mLayoutManagerOrientation);
    m1LevelMenuAdapter.setMenuHeight((int) mLevel1MenuItemHeight);
    m1LevelMenuAdapter.setOnMenuClickListener(new OnMenuClickListener() {
        @Override
        public void onMenuClick(int level1Index, int level2Index, int level3Index) {
            dealMenuClickEvent(level1Index, level2Index, level3Index);
        }
    });
    invalidateViewsAttr();

    recyclerView = new RecyclerView(mContext, attrs, defStyleAttr);
    recyclerView.setId(R.id.recyclerView);
    mLayoutManager = new LinearLayoutManager(mContext);
    mLayoutManager.setOrientation(mLayoutManagerOrientation);
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setBackgroundColor(mLevel1MenuLayoutBgColor);

    LayoutParams params = new LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    recyclerView.setLayoutParams(params);

    addView(recyclerView);
}
 
Example 3
Source File: GifListActivityTest.java    From redux-android-sample with Apache License 2.0 4 votes vote down vote up
private RecyclerView getRecyclerView() {
    RecyclerView recyclerView = (RecyclerView) getFeedView().getChildAt(0);
    recyclerView.setId(generateViewId());
    return recyclerView;
}
 
Example 4
Source File: PullToRefreshRecyclerView.java    From AndroidBase with Apache License 2.0 4 votes vote down vote up
@Override protected RecyclerView createRefreshableView(Context context, AttributeSet attrs) {
    RecyclerView recyclerView = new RecyclerView(context, attrs);
    recyclerView.setId(R.id.recyclerview);
    return recyclerView;
}