本文整理匯總了Java中android.support.v7.widget.RecyclerView.setHasFixedSize方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.setHasFixedSize方法的具體用法?Java RecyclerView.setHasFixedSize怎麽用?Java RecyclerView.setHasFixedSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.setHasFixedSize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initUiView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initUiView() {
recyclerView = (RecyclerView) findViewById(R.id.user_feeling_recyclerview);
LinearLayoutManager llm = new LinearLayoutManager(this);
recyclerView.setLayoutManager(llm);
recyclerView.addItemDecoration(new SimpleDividerItemDecoration(this));
recyclerView.setHasFixedSize(true);
recyclerView.setAdapter(activityInteractionAdapter);
InfiniteScrollProvider infiniteScrollProvider=new InfiniteScrollProvider();
infiniteScrollProvider.attach(recyclerView,this);
try {
loadFirstPage();
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: initViews
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initViews(View v) {
adapter=new CallAdapter(new ArrayList<HamnetCall>());
recyclerView = (RecyclerView) v.findViewById(R.id.item_recycler_view);
recyclerView.setAdapter(adapter);
recyclerView.setHasFixedSize(true);
LinearLayoutManager mLayoutManager = new LinearLayoutManager(getActivity().getApplicationContext());
mLayoutManager.setReverseLayout(true);
mLayoutManager.setStackFromEnd(true);
recyclerView.setLayoutManager(mLayoutManager);
SharedPreferences sharedPref = this.getActivity().getSharedPreferences("sharedPref", Context.MODE_PRIVATE);
server = sharedPref.getString("server", "http://www.hampager.de:8080");
user = sharedPref.getString("user", "invalid");
password = sharedPref.getString("pass", "invalid");
admin = sharedPref.getBoolean("admin", true);
fetchJSON(server, user, password, admin);
}
示例3: onCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.quran_list, container, false);
final Context context = getActivity();
mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
final QuranListAdapter adapter =
new QuranListAdapter(context, mRecyclerView, getJuz2List(), false);
mRecyclerView.setAdapter(adapter);
return view;
}
示例4: onCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_video_pager, container, false);
listView = (RecyclerView) view.findViewById(R.id.list);
listView.setHasFixedSize(true);
listView.setLayoutManager(new StaggeredGridLayoutManager(1, LinearLayoutManager.VERTICAL));
List<ItemList> lists = new ArrayList<ItemList>();
videoadapter = new VideoAdapter(lists);
listView.setAdapter(videoadapter);
mPresent = new VideoPresenter((VideoData.View) this);
srfLayout = (SwipeRefreshLayout) view.findViewById(R.id.srf_layout);
srfLayout.setOnRefreshListener(this);
srfLayout.post(() -> onRefresh());
return view;
}
示例5: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_food_list);
//FIrebase
database= FirebaseDatabase.getInstance();
foodList = database.getReference("Foods");
recyclerView = (RecyclerView)findViewById(R.id.recycler_food);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
//Get intent here
if(getIntent() != null)
categoryId = getIntent().getStringExtra("CategoryId");
if(!categoryId.isEmpty() && categoryId !=null){
loadListFood(categoryId);
}
}
示例6: initView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initView(Context context) {
mContext = context;
View view = LayoutInflater.from(context).inflate(R.layout.pull_loadmore_layout, null);
mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipeRefreshLayout);
mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_green_dark, android.R.color.holo_blue_dark, android.R.color.holo_orange_dark);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayoutOnRefresh(this));
mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
mRecyclerView.setVerticalScrollBarEnabled(true);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.addOnScrollListener(new RecyclerViewOnScroll(this));
mRecyclerView.setOnTouchListener(new onTouchRecyclerView());
mFooterView = view.findViewById(R.id.footerView);
loadMoreLayout = (LinearLayout) view.findViewById(R.id.loadMoreLayout);
loadMoreText = (TextView) view.findViewById(R.id.loadMoreText);
mFooterView.setVisibility(View.GONE);
this.addView(view);
}
示例7: initializeRecyclerView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@SuppressWarnings({"unchecked", "ConstantConditions"})
private void initializeRecyclerView() {
// Initialize Adapter and RecyclerView
// true = it makes use of stableIds, I strongly suggest to implement 'item.hashCode()'
mAdapter = new FlexibleAdapter<>(DatabaseService.getInstance().getDatabaseList(), getActivity(), true);
mAdapter.addListener(getActivity())
// Experimenting NEW features (v5.0.0)
.setAnimationOnScrolling(true)
.setAnimationOnReverseScrolling(true);
mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(createNewLinearLayoutManager());
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setHasFixedSize(true); //Size of RV will not change
// NOTE: Use default item animator 'canReuseUpdatedViewHolder()' will return true if
// a Payload is provided. FlexibleAdapter is actually sending Payloads onItemChange.
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
// Custom divider item decorator with 24dpi as empty space between sections
mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), 0, 24));
mAdapter.setDisplayHeadersAtStartUp(true) //Show Headers at startUp!
.setStickyHeaders(true) //Make headers sticky
// Endless scroll with 1 item threshold
.setEndlessScrollListener(this, new ProgressItem())
.setEndlessScrollThreshold(1); //Default=1
SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.swipeRefreshLayout);
swipeRefreshLayout.setEnabled(true);
mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, SelectableAdapter.MODE_IDLE);
}
示例8: onFinishInflate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onFinishInflate() {
super.onFinishInflate();
View root = inflate(getContext(), R.layout.fancy_tab_layout, this);
tabsContainer = (RecyclerView) root.findViewById(R.id.tabs_container);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()) {
@Override
public boolean canScrollHorizontally() {
return canScroll;
}
};
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
tabsContainer.setLayoutManager(layoutManager);
tabsContainer.setHasFixedSize(true);
if (fancyTabAdapter != null){
tabsContainer.setAdapter(fancyTabAdapter);
}
if (tabFormat == IMGTITLE) {
titleTV = (TextView) root.findViewById(R.id.fancy_title);
titleTV.setVisibility(View.VISIBLE);
}
}
示例9: init
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void init() {
setTheme(android.R.style.Theme_DeviceDefault_Wallpaper);
displayMetrics = getResources().getDisplayMetrics();
adapter = new IconAdapter();
layoutManager = new GridLayoutManager(this, calculateGridNum());
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return adapter.isCate(position) ? layoutManager.getSpanCount() : 1;
}
});
RecyclerView recyclerView = new RecyclerView(this);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
ViewGroup.LayoutParams lpRv = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
recyclerView.setLayoutParams(lpRv);
recyclerView.setBackgroundColor(0x80808080); // 保證圖標視覺
setContentView(recyclerView);
}
示例10: setupByConfig
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
void setupByConfig(Config config, boolean waitForFirstLayout) throws Throwable {
mRecyclerView = new RecyclerView(getActivity());
mRecyclerView.setHasFixedSize(true);
mTestAdapter = config.mTestAdapter == null ? new TestAdapter(config.mItemCount)
: config.mTestAdapter;
mRecyclerView.setAdapter(mTestAdapter);
mLayoutManager = new WrappedLinearLayoutManager(getActivity(), config.mOrientation,
config.mReverseLayout);
mLayoutManager.setStackFromEnd(config.mStackFromEnd);
mLayoutManager.setRecycleChildrenOnDetach(config.mRecycleChildrenOnDetach);
mRecyclerView.setLayoutManager(mLayoutManager);
if (waitForFirstLayout) {
waitForFirstLayout();
}
}
示例11: doCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void doCreateView(View view) {
setHasOptionsMenu(true);
mAppListActivity = ((AppListActivity) getActivity());
new AppsPresenter(mAppListActivity, this);
RecyclerView mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
mRecyclerView.setHasFixedSize(true);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.addItemDecoration(new DividerItemDecoration(mAppListActivity, layoutManager.getOrientation()));
mAppInfoDBController = new AppInfoDBController(mAppListActivity);
Set<String> appPackageSet = new HashSet<>();
if (mAppListActivity.getIntent().getBooleanExtra(EXTRA_MANUAL_SHORTCUT, false)) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
ShortcutManager manager = mAppListActivity.getSystemService(ShortcutManager.class);
for (ShortcutInfo shortcutInfo : manager.getDynamicShortcuts()) {
appPackageSet.add(shortcutInfo.getId());
}
}
} else {
List<AppInfo> appInfoSet = mAppInfoDBController.getDisableApps(AppInfoDBOpenHelper.TABLE_NAME_APP_INFO);
for (AppInfo appInfo : appInfoSet) {
appPackageSet.add(appInfo.getAppPackageName());
}
}
mAppListAdapter = new AppListAdapter(mAppListActivity, mRecyclerView, appPackageSet);
mRecyclerView.setAdapter(mAppListAdapter);
int tabCategory = getArguments().getInt(TAB_CATEGORY);
mPresenter.getApps(tabCategory == 0 ? AppsRepository.APPS_FLAG_USER : AppsRepository.APPS_FLAG_SYSTEM);
initListener();
}
示例12: setUpPreviewRecyclerView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void setUpPreviewRecyclerView(View view) {
mDetectionViewAdapter = new DetectionViewAdapter(this);
mPreviewRecyclerView = (RecyclerView) view.findViewById(R.id.preview_list);
mPreviewRecyclerView.setHasFixedSize(false);
LinearLayoutManager layout = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, true);
layout.setStackFromEnd(true);
mPreviewRecyclerView.setLayoutManager(layout);
mPreviewRecyclerView.setAdapter(mDetectionViewAdapter);
}
示例13: initView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
protected void initView() {
TextView textView = (TextView) findViewById(R.id.click_me);
textView.setTag(TrackerConstants.VIEW_TAG_UNIQUE_NAME, "home_click_me");
textView.setOnClickListener(clickListener);
horizontalScrollView = (LinearLayout) findViewById(R.id.horizontal_scrollview);
int size = (int) getResources().getDisplayMetrics().density * 100;
for (int i = 0; i < 10; i++) {
TextView item = new TextView(this);
item.setTextColor(Color.WHITE);
item.setGravity(Gravity.CENTER);
item.setTag(TrackerConstants.VIEW_TAG_UNIQUE_NAME, "home_horizontalScrollView_item " + i);
item.setText("item " + i);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(size, size);
params.gravity = Gravity.CENTER;
horizontalScrollView.addView(item, params);
}
mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);
mRecyclerView.setHasFixedSize(true);
mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);
for (int i = 0; i < myDataset.length; i++) {
myDataset[i] = "item " + i;
}
mAdapter = new MyAdapter(myDataset);
mRecyclerView.setAdapter(mAdapter);
}
示例14: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_adapter_use);
mRecyclerView = (RecyclerView) findViewById(R.id.rv_list);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
initAdapter();
initMenu();
initView();
}
示例15: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rv=(RecyclerView)findViewById(R.id.list);
// 兩列
int spanCount = 2;
// StaggeredGridLayoutManager管理RecyclerView的布局。
RecyclerView.LayoutManager mLayoutManager = new StaggeredGridLayoutManager(
spanCount, StaggeredGridLayoutManager.VERTICAL);
rv.setLayoutManager(mLayoutManager);
rv.setHasFixedSize(true);
//mLayoutManager.setMeasuredDimension(500,600);
Logger.d(TAG,"onCreate");
net.getBingWall().subscribeWith(bingObserver());
new Thread(new Runnable() {
@Override public void run() {
Samba smb=new Samba();
smb.getShare("smb://sf:[email protected]/ffplay/");
}
}).start();
}