當前位置: 首頁>>代碼示例>>Java>>正文


Java RecyclerView.setAdapter方法代碼示例

本文整理匯總了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;
                }
            }
    );
}
 
開發者ID:florent37,項目名稱:RxRetroJsoup,代碼行數:25,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:Elbehiry,項目名稱:Viajes,代碼行數:27,代碼來源:MapFragment.java

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

}
 
開發者ID:DecentralizedAmateurPagingNetwork,項目名稱:DAPNETApp,代碼行數:19,代碼來源:CallFragment.java

示例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;
}
 
開發者ID:fekracomputers,項目名稱:IslamicLibraryAndroid,代碼行數:21,代碼來源:SearchResultFragment.java

示例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;
}
 
開發者ID:dev-prajwal21,項目名稱:CustomerSupportDesk,代碼行數:22,代碼來源:ComplaintsFragment.java

示例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());

}
 
開發者ID:yippeesoft,項目名稱:NotifyTools,代碼行數:22,代碼來源:ViewBuilder.java

示例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);
}
 
開發者ID:gjiazhe,項目名稱:LayoutSwitch,代碼行數:16,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:RutoTV,項目名稱:9AnimeAndroid,代碼行數:12,代碼來源:EpisodeFragment.java

示例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;
}
 
開發者ID:sloiza,項目名稱:changApp,代碼行數:15,代碼來源:TileContentFragment.java

示例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;
}
 
開發者ID:TORU0239,項目名稱:android-design-library-master,代碼行數:12,代碼來源:ListContentFragment.java

示例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);
}
 
開發者ID:byvlstr,項目名稱:fluentAppBar,代碼行數:9,代碼來源:FluentAppBar.java

示例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();
        }
    });
}
 
開發者ID:bridgefy,項目名稱:bridgefy-android-samples,代碼行數:32,代碼來源:MainActivity.java

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

}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:RxMixedLinearActivity.java

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

}
 
開發者ID:tortuvshin,項目名稱:sign-android,代碼行數:39,代碼來源:DetailsActivity.java

示例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);
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:8,代碼來源:ChooseSubjectDialogFragment.java


注:本文中的android.support.v7.widget.RecyclerView.setAdapter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。