本文整理匯總了Java中android.support.v7.widget.LinearLayoutManager.getOrientation方法的典型用法代碼示例。如果您正苦於以下問題:Java LinearLayoutManager.getOrientation方法的具體用法?Java LinearLayoutManager.getOrientation怎麽用?Java LinearLayoutManager.getOrientation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.LinearLayoutManager
的用法示例。
在下文中一共展示了LinearLayoutManager.getOrientation方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setupRecyclerView
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
public static void setupRecyclerView(EmptySupportedRecyclerView recyclerView,
Context context, View emptyView) {
// set view to display when there is any content
recyclerView.setEmptyView(emptyView);
recyclerView.setHasFixedSize(true);
// set layout manager as linear
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
recyclerView.setLayoutManager(linearLayoutManager);
// add divider between items
DividerItemDecoration dividerItemDecoration =
new DividerItemDecoration(context, linearLayoutManager.getOrientation());
recyclerView.addItemDecoration(dividerItemDecoration);
}
示例2: isHorizontalView
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
private static boolean isHorizontalView(View view) {
if (view instanceof ViewPager || view instanceof HorizontalScrollView
|| view instanceof WebView) {
return true;
}
try {
if (view instanceof RecyclerView) {
RecyclerView recyclerView = (RecyclerView) view;
RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
if (manager != null) {
if (manager instanceof LinearLayoutManager) {
LinearLayoutManager linearManager = ((LinearLayoutManager) manager);
if (linearManager.getOrientation() == LinearLayoutManager.HORIZONTAL)
return true;
} else if (manager instanceof StaggeredGridLayoutManager) {
StaggeredGridLayoutManager gridLayoutManager = (StaggeredGridLayoutManager) manager;
if (gridLayoutManager.getOrientation() == StaggeredGridLayoutManager.HORIZONTAL)
return true;
}
}
}
} catch (NoClassDefFoundError e) {
e.printStackTrace();
}
return false;
}
示例3: setLayoutManager
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
@Override
public void setLayoutManager(LayoutManager layout) {
super.setLayoutManager(layout);
canpull = true;
if (layout instanceof LinearLayoutManager) {
linearLayoutManager = (LinearLayoutManager) layout;
if (linearLayoutManager.getOrientation() != VERTICAL)
canpull = false;
} else if (layout instanceof GridLayoutManager) {
gridLayoutManager = (GridLayoutManager) layout;
if (gridLayoutManager.getOrientation() != VERTICAL)
canpull = false;
} else if (layout instanceof StaggeredGridLayoutManager) {
staggeredGridLayoutManager = (StaggeredGridLayoutManager) layout;
if (staggeredGridLayoutManager.getOrientation() != VERTICAL)
canpull = false;
}
}
示例4: onCreate
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
layoutManager.getOrientation());
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(dividerItemDecoration);
// Pass in null cursor; Cursor with plant data filled in loader's onLoadFinished
mAdapter = new PlantAdapter(null);
recyclerView.setAdapter(mAdapter);
// Kick off the loader
getSupportLoaderManager().initLoader(PLANT_LOADER, null, this);
}
示例5: getOrientation
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
private int getOrientation(RecyclerView parent) {
if (mOrientation == -1) {
if (parent.getLayoutManager() instanceof LinearLayoutManager) {
LinearLayoutManager layoutManager = (LinearLayoutManager) parent.getLayoutManager();
mOrientation = layoutManager.getOrientation();
} else {
throw new IllegalStateException(
"DividerItemDecoration can only be used with a LinearLayoutManager.");
}
}
return mOrientation;
}
示例6: initializeList
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
public void initializeList(RecyclerView rv) {
LinearLayoutManager lm = new LinearLayoutManager(context);
rv.setLayoutManager(lm);
adapter = new FolderChooserAdapter(context, new ArrayList<Folder>(), this);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(rv.getContext(),
lm.getOrientation());
rv.addItemDecoration(dividerItemDecoration);
rv.setAdapter(adapter);
interactor.loadFolders(null);
}
示例7: setRecycler
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
public void setRecycler(RecyclerView rv) {
LinearLayoutManager lm = new LinearLayoutManager(context);
rv.setLayoutManager(lm);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(rv.getContext(),
lm.getOrientation());
rv.addItemDecoration(dividerItemDecoration);
ArrayList<AudioBook> items = new ArrayList<>();
adapter = new AudioBookAdapter(context, items, this);
rv.setAdapter(adapter);
interactor.loadAllAudioBooks();
}
示例8: initRecyclerView
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
private void initRecyclerView() {
recyclerView = (RecyclerView) findViewById(R.id.activity_select_language_recycler_language);
recyclerView.setHasFixedSize(true);
LinearLayoutManager layoutManager = new LinearLayoutManager(SelectLanguageActivity.this);
recyclerView.setLayoutManager(layoutManager);
adapter = new LanguageAdapter(createDataset(), new OnItemClickListener() {
@Override
public void onItemClick(int position) {
//Toast.makeText(SelectLanguageActivity.this, "position = " + position, Toast.LENGTH_SHORT).show();
returnSelectedLanguage(adapter.getItem(position).getName());
}
});
recyclerView.setAdapter(adapter);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(SelectLanguageActivity.this,
layoutManager.getOrientation());
recyclerView.addItemDecoration(dividerItemDecoration);
EditText edtFilter = (EditText) findViewById(R.id.activity_select_language_edit_text_filter);
unsubscribeOnStop(RxTextView
.textChanges(edtFilter)
.debounce(800, TimeUnit.MILLISECONDS)
.subscribe(new Action1<CharSequence>() {
@Override
public void call(final CharSequence charSequence) {
adapter.getFilter().filter(charSequence.toString());
}
}));
}
示例9: onCreateView
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_location, container, false);
// ButterKnife Bind
ButterKnife.bind(this, rootView);
setHasOptionsMenu(true);
// Use a linear layout manager
mLinearLayoutManager = new LinearLayoutManager(getContext());
mRecyclerView.setLayoutManager(mLinearLayoutManager);
// Get location services
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(getContext());
// Bind SnackBar
mSnackBar = Snackbar.make(rootView.findViewById(R.id.fragment_location_coordinator_layout),
"Location Permission Denied", Snackbar.LENGTH_INDEFINITE);
// Decorate the recycler view
DividerItemDecoration dividerItemDecoration =
new DividerItemDecoration(mRecyclerView.getContext(), mLinearLayoutManager.getOrientation());
mRecyclerView.addItemDecoration(dividerItemDecoration);
// Check for internet connectivity
mInternetConnectivity = new InternetConnectivity(getContext());
return rootView;
}
示例10: setListData
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
public void setListData(List<ListItem> listOfData) {
this.listOfData = listOfData;
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
adapter = new CustomAdapter();
recyclerView.setAdapter(adapter);
DividerItemDecoration itemDecoration = new DividerItemDecoration(
recyclerView.getContext(),
layoutManager.getOrientation()
);
itemDecoration.setDrawable(
ContextCompat.getDrawable(
getActivity(),
R.drawable.divider_white
)
);
recyclerView.addItemDecoration(
itemDecoration
);
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(createHelperCallback());
itemTouchHelper.attachToRecyclerView(recyclerView);
}
示例11: setupRecyclerView
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
private void setupRecyclerView() {
LinearLayoutManager layoutManager = new LinearLayoutManager(this,
LinearLayoutManager.VERTICAL, false);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(
recipesListView.getContext(), layoutManager.getOrientation());
recipesListView.addItemDecoration(dividerItemDecoration);
recipesListAdapter = new SimpleRecipeListAdapter(ingredientsWidgetProviderConfigurationPresenter);
recipesListView.setAdapter(recipesListAdapter);
recipesListView.setLayoutManager(layoutManager);
recipesListView.setHasFixedSize(true);
}
開發者ID:ecarrara-araujo,項目名稱:yabaking,代碼行數:13,代碼來源:IngredientsWidgetProviderConfigurationActivity.java
示例12: initRecyclerView
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
private void initRecyclerView(List<NRAccount> accounts) {
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
DividerItemDecoration lineDecor = new DividerItemDecoration(recyclerView.getContext(),
layoutManager.getOrientation());
progressBar.setVisibility(View.GONE);
recyclerView.setItemAnimator(null);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(lineDecor);
recyclerView.setAdapter(new AccountsListAdapter(accounts, this));
}
示例13: onCreateViewHolder
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
int layoutResId = R.layout.item_one;
RecyclerView.LayoutManager layoutManager = ((RecyclerView) parent).getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) {
LinearLayoutManager manager = (LinearLayoutManager) layoutManager;
if (manager.getOrientation() == OrientationHelper.HORIZONTAL) {
layoutResId = R.layout.item_two;
}
}
View view = mInflater.inflate(layoutResId, parent, false);
return new TextViewHolder(view);
}
示例14: initRecyclerView
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
private void initRecyclerView() {
rvSearch = view.findViewById(R.id.recyclerViewSearch);
clickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
int position = rvSearch.getChildAdapterPosition(v);
if (data[position] instanceof User) {
User clickedUser = (User) data[position];
startActivity(new Intent(getContext(), ChatActivity.class)
.putExtra("uid", clickedUser.uid)
.putExtra("cid", Utils.getController().getMessengerDatabase().getChatWith(clickedUser.uid))
.putExtra("cname", clickedUser.uname)
.putExtra("ctype", Chat.ChatType.PRIVATE.toString()));
} else {
Chat clickedChat = (Chat) data[position];
startActivity(new Intent(getContext(), ChatActivity.class)
.putExtra("cid", clickedChat.cid)
.putExtra("cname", clickedChat.cname)
.putExtra("ctype", Chat.ChatType.GROUP.toString()));
}
}
};
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
DividerItemDecoration mDividerItemDecoration = new DividerItemDecoration(
rvSearch.getContext(),
linearLayoutManager.getOrientation()
);
rvSearch.addItemDecoration(mDividerItemDecoration);
rvSearch.setLayoutManager(linearLayoutManager);
rvSearch.setAdapter(new HybridAdapter(getActivity().getLayoutInflater()));
}
示例15: onCreate
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shopping_cart);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.shopping_cart_title);
setSupportActionBar(toolbar);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mTextViewEmptyCart = (TextView) findViewById(R.id.text_view_empty_cart);
mTextViewTotalPrice = (TextView) findViewById(R.id.text_view_total_price);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(
mRecyclerView.getContext(), layoutManager.getOrientation());
mCartAdapter = new ShoppingCartAdapter();
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.addItemDecoration(dividerItemDecoration);
mRecyclerView.setAdapter(mCartAdapter);
mButtonCheckout = (Button) findViewById(R.id.button_cart_checkout);
mButtonCheckout.setOnClickListener(this);
getSupportLoaderManager().initLoader(SHOPPING_CART_LOADER, null, this);
}