本文整理匯總了Java中android.support.v7.widget.RecyclerView.setAdapter方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.setAdapter方法的具體用法?Java RecyclerView.setAdapter怎麽用?Java RecyclerView.setAdapter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.setAdapter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
recyclerView.setLayoutManager(new LinearLayoutManager(getBaseContext()));
adapter = new Adapter();
recyclerView.setAdapter(adapter);
loadWithRetroJsoup();
Observable.zip(
Observable.just(""),
Observable.just("&"),
new BiFunction<String, String, String>(){
@Override
public String apply(@NonNull String s, @NonNull String s2) throws Exception {
return null;
}
}
);
}
示例2: onCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View mRootView = inflater.inflate(R.layout.fragment_map,container,false);
hotels = new ArrayList<>();
SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map_item);
mapFragment.getMapAsync(this);
recyclerView = (RecyclerView) mRootView.findViewById(R.id.map_recycler_view);
recyclerView.setHasFixedSize(true);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
linearLayoutManager.setOrientation(LinearLayout.HORIZONTAL);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
mAdapter = new CardViewAdapter(hotels);
mAdapter.setActionListner(this);
recyclerView.setAdapter(mAdapter);
if (mPresenter != null)
mPresenter.loadHotels();
return mRootView;
}
示例3: 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);
}
示例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_search_result_list, container, false);
RecyclerView recyclerView = view.findViewById(R.id.list);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
new SearchAsyncTask().execute(new SearchRequest(mSearchQuery, new SearchOptions(), requestedSearchBookIds, !mIsGlobalSearch));
searchResultRecyclerViewAdapter = new SearchResultRecyclerViewAdapter(bookSearchResultsContainerList, this, getContext());
recyclerView.setAdapter(searchResultRecyclerViewAdapter);
mProgressBar = view.findViewById(R.id.search_progress);
mProgressBar.setMax(requestedSearchBookIds.size());
mTotalBooksTextView = view.findViewById(R.id.total_books);
mTotalBooksTextView.setText(String.valueOf(requestedSearchBookIds.size()));
mNumberOfAlreadySearchedBooksTextView = view.findViewById(R.id.current_book);
mNumberOfAlreadySearchedBooksTextView.setText("0");
return view;
}
示例5: onCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_complaints, container, false);
noContentLabel = (TextView) view.findViewById(R.id.noContentLabel);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
RecyclerView.LayoutManager rlm = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(rlm);
recyclerView.setAdapter(commonAdapter);
if (NetworkHelper.isNetworkAvailable(getContext())) {
showDialog();
fetchComplaints();
} else {
ToastHelper.showToast(getContext(), "Check your internet connection");
}
return view;
}
示例6: initView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void initView(){
//initdata();
poemData = new ArrayList<SongCi>();
poemRecyclerView = (RecyclerView) cxt.findViewById(R.id.recycler_view);
poemAdapter = new PoemAdapter(cxt, poemData,poemRecyclerView);
poemRecyclerView.setAdapter(poemAdapter);//設置適配器
poemRecyclerView.setVerticalScrollBarEnabled(true);
//設置布局管理器 , 將布局設置成縱向
LinearLayoutManager
linerLayoutManager = new LinearLayoutManager(cxt, LinearLayoutManager.VERTICAL, false);
poemRecyclerView.setLayoutManager(linerLayoutManager);
//設置分隔線
poemRecyclerView.addItemDecoration(new DividerItemDecoration(cxt , DividerItemDecoration.VERTICAL));
//設置增加或刪除條目動畫
poemRecyclerView.setItemAnimator(new DefaultItemAnimator());
}
示例7: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
initItemsData();
gridLayoutManager = new GridLayoutManager(this, SPAN_COUNT_ONE);
itemAdapter = new ItemAdapter(items, gridLayoutManager);
recyclerView = (RecyclerView) findViewById(R.id.rv);
recyclerView.setAdapter(itemAdapter);
recyclerView.setLayoutManager(gridLayoutManager);
}
示例8: onCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
RecyclerView view = (RecyclerView)inflater.inflate(R.layout.content_recyclerview, parent, false);
view.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
view.setHasFixedSize(true);
view.setLayoutManager(new LinearLayoutManager(getActivity()));
view.setAdapter(new EpisodeAdapter(episodes, (ItemClickListener<Episode>)getParentFragment()));
return view;
}
示例9: onCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
RecyclerView recyclerView = (RecyclerView) inflater.inflate(
R.layout.recycler_view, container, false);
ContentAdapter adapter = new ContentAdapter(recyclerView.getContext());
recyclerView.setAdapter(adapter);
recyclerView.setHasFixedSize(true);
// Set padding for Tiles
int tilePadding = getResources().getDimensionPixelSize(R.dimen.tile_padding);
recyclerView.setPadding(tilePadding, tilePadding, tilePadding, tilePadding);
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
return recyclerView;
}
示例10: onCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
RecyclerView recyclerView = (RecyclerView) inflater.inflate(
R.layout.recycler_view, container, false);
ContentAdapter adapter = new ContentAdapter(recyclerView.getContext());
recyclerView.setAdapter(adapter);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
return recyclerView;
}
示例11: setNavigationMenu
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void setNavigationMenu(@MenuRes int menuRes, OnClickListener onClickListener) {
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.nav_items_recycler);
recyclerView.setNestedScrollingEnabled(false);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
menuNavigationItemsAdapter = new MenuNavigationItemsAdapter(getContext(), menuRes, onClickListener,
foregroundColour);
recyclerView.setAdapter(menuNavigationItemsAdapter);
}
示例12: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Configure the Toolbar
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setTitle(getTitle());
RecyclerView recyclerView = findViewById(R.id.peer_list);
recyclerView.setAdapter(peersAdapter);
Bridgefy.initialize(getApplicationContext(), new RegistrationListener() {
@Override
public void onRegistrationSuccessful(BridgefyClient bridgefyClient) {
// Start Bridgefy
startBridgefy();
}
@Override
public void onRegistrationFailed(int errorCode, String message) {
Toast.makeText(getBaseContext(), getString(R.string.registration_error),
Toast.LENGTH_LONG).show();
}
});
}
示例13: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mixed);
setTitle("Rx混合刷新線性排布");
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
helper = new RxAdapterHelper(initData(), RxAdapterHelper.MODE_MIXED);
SimpleRxHelperAdapter adapter = new SimpleRxHelperAdapter(helper);
adapter.addHeaderView(View.inflate(this, R.layout.layout_header, null));
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(adapter);
}
示例14: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details);
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_vertical);
mLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
mRecyclerView.setLayoutManager(mLayoutManager);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
SharedPreferences sharedPreferences = getSharedPreferences(CircleMenuActivity.PREFER_NAME, 0);
String item = sharedPreferences.getString("item", "");
catName = sharedPreferences.getString("item_category", "");
getSupportActionBar().setTitle(sharedPreferences.getString("item_title", ""));
dImage = (ImageView)findViewById(R.id.details_image);
if (item.toString().contains(".")) {
dImage.setImageDrawable(loadGifDrawable(getApplicationContext(), item+"gif"));
} else {
dImage.setImageBitmap(loadBitmapFromAssets(getApplicationContext(), item+".JPG"));
}
final AssetManager assetManager = getAssets();
try {
String[] filelist = assetManager.list("");
filelistInSubfolder = assetManager.list(sharedPreferences.getString("item_category", ""));
} catch (IOException e) {
e.printStackTrace();
} catch (NullPointerException npe) {
Toast.makeText(getApplicationContext(), "Алдаа гарлаа !!!", Toast.LENGTH_LONG).show();
}
mAdapter = new MyAdapter(filelistInSubfolder,filelistInSubfolder);
mRecyclerView.setAdapter(mAdapter);
}
示例15: initView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initView(View view) {
RecyclerView recyclerView = view.findViewById(R.id.recycle_view);
recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
mAdapter = new ChooseSubjectAdapter(mActivity, new ArrayList<Subject>(), new ArrayList<Teacher>(), mChooseSubjectList);
@SuppressWarnings("unchecked") SwingBottomInAnimationAdapter animatorAdapter = new SwingBottomInAnimationAdapter(mAdapter, recyclerView);
recyclerView.setAdapter(animatorAdapter);
}