android,material-design,recyclerview,android-recyclerview
Ok. So I found a great way to change the color dynamically for things like the new cards feature on Material Design. A how-to can be found here. This code allows you to generate the palette synchronously when you have access to the underlying image loading thread. To have access...
android,onclick,onclicklistener,recyclerview,android-recyclerview
The constructor of MyAdapter takes also an object of a class that implements ClickListener. You could, for instance, let your Activity/Fragment implements that Interface and use this as parameter public class MainActivity extends Activity implements ViewHolder.ClickListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // .... mAdapter = new...
android,recyclerview,gridlayoutmanager
I've solved the problem by using only one RecyclerView and using getItemViewType(int position) method in the adapter. Example here.
android,android-adapter,recyclerview,android-recyclerview,recycler-adapter
I created a wrapper around my adapter using this gist.And after that i can include my own layout and viewholder for my header and footer as well as the rest of the items. public class SplitMembersAdapter extends HeaderFooterRecyclerViewAdapter implements AutoCompleteContactTextView.ContactSelectListener{ private final ArrayList<SplitMember> mSplitMembersList; private final ImageLoader mImageLoader; private static...
android,android-layout,recyclerview,android-cardview,cardslib
Card.OnCardClickListener is an Interface. You must create the class that defines how the functions within the interface are to be used. Try this: card.setOnClickListener(new Card.OnCardClickListener() { @Override public void onClick(Card card, View view) { // This will execute when the the card is clicked } }); Source for answer: https://github.com/gabrielemariotti/cardslib/blob/master/doc/CARD.md#clickable-card...
android,onclick,position,recyclerview
You need to pass data in a bundle and add it to the intent of the new activity. // onClick at recycler Intent intent = new Intent(); intent.setClass(context, Other_Activity.class); intent.putExtra("SOME_ID", position); startActivity(intent); //Second activity @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle extras = getIntent().getExtras(); if (extras != null) {...
android,android-fragments,recyclerview,fragmentpageradapter
I finally solved my problem and here is how : 1 - Change FragmentPagerAdapter to FragmentStatePagerAdapter. The reason for that is that FragmentPagerAdapter does not recreate your Fragments if needed. It keeps everything in memory. So if your Fragment is not fully operational when it is created, or if you...
Since RecyclerView both contains scrollTo and smoothScroll methods, I would think that scrollTo would result in a instant jump to the specified position, without scrolling. Edited Apparently, the direct links did not work. Fixed it. Fairly new here....
android,recyclerview,android-cardview,android-viewholder
You need to make Arraylist of booleans for the minus button you can set it in your model or in the adapter whatever you want, this arraylist will contains the status of the button so it will be true by default unless the user clicked so it will change to...
In MainActivity ArrayList<String> list = new ArrayList<>(); list.add("something1"); list.add("something2"); RecyclerView recyclerView = (RecyclerView)findViewById(R.id.rec); recyclerView.setHasFixedSize(true); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); recyclerView.setLayoutManager(linearLayoutManager); MenuRecAdapter menuRecAdapter = new MenuRecAdapter(list); recyclerView.setAdapter(menuRecAdapter); RecyclerView...
The solution is to force the cards of the RecyclerView to a fixed size. Replace this: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@id/statusIcon" android:maxHeight="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> With this: <?xml version="1.0"...
Check out this Gist from Pascal Welsch: This helped me when I first started using the RecyclerView over the ListView. import android.support.v7.widget.RecyclerView; import java.util.Collections; import java.util.Comparator; import java.util.List; /** * Created by pascalwelsch on 04.07.14. */ public abstract class ArrayAdapter<T, VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> { private List<T> mObjects; public...
android,android-viewpager,recyclerview,fragmentpageradapter
Do not use any fragments on any recycling views like list view, recycler view etc. Fragments are attached to its container, in recycler view container will be changed frequently, as it is getting recycled. It will trouble later. Better you can change the view pager to vertical scrolling view pager....
The correct solution seems to be using a wrapper object with two properties: the original (unmodifiable) object, and a boolean indicating whether the item is expanded or collapsed. Then in the onBindViewHolder() method of the RecyclerView's adapter, you have to set your views to expanded or collapsed depending on the...
At first, there is a bug in your code - you have to remove the condition from onBindViewHolder. All ImageView instances has to be updated each time they are about to display. @Override public void onBindViewHolder(ViewHolder holder, int position) { String url = images.get(position); ImageLoader.getInstance().displayImage(url, holder.imgView); } The reloading part:...
If you change just your list mNavTitles that won't change the adapter. You need to change it inside adapter, just like you did in constructor: public void updateList(String[] mNavTitles) { this.mNavTitles = mNavTitles; } And then you call notifyDataSetChanged which will work out if anything changed or added and will...
android,selection,recyclerview,highlighting
I actually just implemented this in an app I am working on. So this method worked: First create a variable to track the current selected position at the top of your adapter: private int selectedItem; Then in your Adapter constructor initiate the selectedItem value you would like: public NavDrawerMenuListAdapter(Context context,...
android,imageview,recyclerview
As from I see you need a vertical ViewPager. I'm using castorflex/VerticalViewPager library for achieving that for one of my projects. It works just like a ViewPager, no code changes as I can see It's just a copy paste from the v19 ViewPager available in the support lib, where he...
android,animation,recyclerview
I have found the correct solution to just remove the animateChange. It's very simple. Google has implemented the functionality. RecyclerView.gettItemAnimator().setSupportsChangeAnimations(false); ...
java,android,listview,recyclerview,slidingpanelayout
The solution: Prevent the RecyclerView from intercepting touch events given the following condition: 10% < sliding pane offset < 90% i.e ViewParent parent = ...; // Should be the RecyclerView if (slideOffset > 0.1 && slideOffset < 0.9) { parent.requestDisallowInterceptTouchEvent(true); } else { parent.requestDisallowInterceptTouchEvent(false); } ...
android,listview,recyclerview,navigationview
You can just nest the ListView or RecyclerView inside the NavigationView. <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout android:id="@+id/drawer_layout" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context=".MainActivity"> <FrameLayout...
android,android-adapter,recyclerview
RecyclerView's Adapter doesn't come with many methods otherwise available in ListView's adapter. But your swap can be implemented quite simply as: class MyRecyclerAdapter{ List<Data> data; ... public void swap(ArrayList<Data> datas){ data.clear(); data.addAll(datas); notifyDataSetChanged(); } } Also there is a difference between list.clear(); list.add(data); and list = newList; The first is...
android,listview,android-sqlite,recyclerview
Okay I finally got it working and It was actually quite simple... //.... if (numberofbits > 50) { db = new DatabaseHandler(getActivity()); db.updateImages(new Images(dbid, "Downloaded", imagename_)); //This is what I added: List<Images> listdb = db.getImages(); mAdapter = new ImgAdapter(getActivity(), listdb); recyclerView.setAdapter(mAdapter); db.close(); //populateList(); -> THIS I USED FOR A LISTVIEW...
After playing a bit, I managed that SimpleCallback has a method called getSwipeDirs(). As I have a specific ViewHolder for the not swipable position, I can make use of instanceof to avoid the swipe. If that's not your case, you can perform this control using the position of ViewHolder in...
It was actually a problem in my adapter implementation. I had a Cursor in the overriden onBindViewHolder method and every time it called cursor.moveToNext() the cursor would move forward unless it was the last row in the database. At that point it would stop on that last row. So when...
I haven't worked much with RecyclerView so far, and my guess is the same simple logic as in ListView can be applied here as well: in you RecyclerView.Adapter @Override public void onBindViewHolder(ViewHolder holder, final int position) { // set on click for you imageView holder.mImageView.setOnClickListener(new OnClickListener() { public void onClick(View...
Another way is implement onBindViewHolder(ViewHolder holder, final int position) in your Adapter This method already have position as a third argument. LIKE @Override public void onBindViewHolder(final ViewHolder holder, final int position) { holder.mImageView2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); ...
android,recyclerview,android-recyclerview
Yes, move this code to the createViewHolder, so it will be called only once
java,android,android-view,recyclerview,android-viewholder
You cannot use the position parameter of onBindViewHolder in a callback. If a new item is added above, RecyclerView will not rebind your item so the position is obsolete. Instead, RecyclerView provides a getAdapterPosition method on the ViewHolder. @Override public ViewHolder onCreateViewHolder(final ViewGroup parent, int viewType) { final View view...
android,recyclerview,onscrolllistener
addOnScrollListener(OnScrollListener) means you can add more than one listener to a RecyclerView. removeOnScrollListener(OnScrollListener) means you can remove one of the listeners that attached to a specific RecyclerView. If the arg was set null, it equals to clearOnScrollListeners() method. And, clearOnScrollListeners() let you remove all the listener from a RecyclerView....
scroll,adapter,recyclerview,infinite
The answer is here: http://antonioleiva.com/recyclerview/ All I've had to do is add items to the list of items that's already in the adapter and then use "notifyItemInserted(position)". Same idea for removal. ...
android,recyclerview,android-toolbar
I got it after reading this line on FrameLayout doc - "Child views are drawn in a stack, with the most recently added child on top." So, I interchanged the position of Toolbar and RecyclerView and it worked. Here, Toolbar is rendered after RecyclerView, so it is higher in the...
android,recyclerview,screen-rotation,android-recyclerview,recycler-adapter
Every time you change the rotation of the screen your activity is destroyed and recreated. Caution: Your activity will be destroyed and recreated each time the user rotates the screen. When the screen changes orientation, the system destroys and recreates the foreground activity because the screen configuration has changed and...
android,gradle,dependencies,recyclerview,android-library
Rebuilt the project and clean it
android,toolbar,recyclerview,android-design-library
Probably you need to prevent the RecyclerView from dispatching scrolling events to its parents. private class NoScrollTouchListener implements RecyclerView.OnTouchListener{ private static final int MAX_CLICK_DURATION = 200; private long mStartClickTime; @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { mStartClickTime = SystemClock.currentThreadTimeMillis(); break; } case MotionEvent.ACTION_UP:...
You can use: recyclerView.smoothScrollToPosition(recyclerView.getAdapter().getItemCount()); if ant relevant position . recyclerView.smoothScrollToPosition(0); ref : http://blog.stylingandroid.com/scrolling-recyclerview-part-1/ @Override public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) { LinearSmoothScroller linearSmoothScroller = new LinearSmoothScroller(recyclerView.getContext()) { @Override public PointF computeScrollVectorForPosition(int targetPosition) { return...
java,android,recyclerview,recycler-adapter
I have created a working example of what you are trying to accomplish. The source of the errors you experience is mostly that you don't understand view recycling. I am not going to explain the whole thing to you now, but anyway here is the example: For the example I...
Okay, I solved both issues. recycler.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { MotionEvent e = MotionEvent.obtain(event); Matrix m = new Matrix(); m.setTranslate(0f, -backgroundTranslation); e.transform(m); background.dispatchTouchEvent(e); e.recycle(); return false; } }); This duplicates the recycler touch event and "fixes" it's position. The translation is translationY for the...
android,android-fragments,recyclerview,android-actionmode
The problem seem to be from your onItemLongClicked method of the FragmentToday.java class. It should have been: @Override public boolean onItemLongClicked(int position) { if (actionMode == null) { actionMode = ((AppCompatActivity) getActivity()).startSupportActionMode(actionModeCallback); } toggleSelection(position); return true; } instead of: @Override public boolean onItemLongClicked(int position) { if (actionMode != null) {...
You should not only toggle on, but toggle off too. I.e. try changing this for (Image image: database.getAllData()) { if (image.getUrl().equals(currentImage.getUrl())) { imagesViewHolder.toggleFavorite.setChecked(true); break; } } to this // unchecked by default, unless proven checked below imagesViewHolder.toggleFavorite.setChecked(false); for (Image image: database.getAllData()) { if (image.getUrl().equals(currentImage.getUrl())) { imagesViewHolder.toggleFavorite.setChecked(true); break; } } RecyclerView...
android,android-viewpager,recyclerview,swipeview
You have to use setOnTouchListener for your list row within your adapter like below: yourListRowContent.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_MOVE) { yourViewPager.setPagerEnabled(false); } return true; } }); By using yourViewPager.setPagerEnabled(false); it will dissable your viewpager when you swipe your list content...
Do you have any idea how could I create RoundRectDrawableWithShadow from my BitmapDrawable? Don't do it unless you wish to rewrite your own CardView implementation. RoundRectDrawableWithShadow is a package private class used to take the color you supplied by app:cardBackgroundColor or setCardBackgroundColro(int) and wrap it in a rounded rectangle...
android,recyclerview,android-recyclerview
Don't have much time to analyze your code so im not sure what you've done already, this is how I would do it. First make objects out of those json objects and put them inside a List. Make a method that takes list of those objects and sorts them the...
android,json,recyclerview,android-viewholder
There is one issue that I see that sticks out: vh.IVPoster.Click += delegate { Android.App.FragmentTransaction trans = context.FragmentManager.BeginTransaction(); FullImageView fImage = FullImageView.newInstance(position); vh.IVPoster.SetTag(Resource.Id.ivPoster, position); trans.AddToBackStack(null); trans.Replace(Resource.Id.place_holder, fImage); trans.Commit(); }; Every time your re-use your view holder, it still contains the contents of the previous view holder. What you're doing there...
android,listview,swipe,recyclerview,android-cardview
Use a listview with custom adapter, and call NotifyDatasetChanged after removing an item from the datalist private void removeListItem(View rowView, final int positon) { Animation anim = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right); anim.setDuration(500); rowView.startAnimation(anim); new Handler().postDelayed(new Runnable() { public void run() { values.remove(positon);//remove the current content from the array adapter.notifyDataSetChanged();//refresh you list }...
android,adapter,recyclerview,smooth-scrolling
I guess you are hoping that when do while is finished, scroll will be complete. It is not how it works, scrolling happens in animation frame and if you were to put a while loop waiting for it to finish, your app will freeze because you'll be blocking main thread....
java,android,listview,android-viewpager,recyclerview
You have to extend FragmentPagerAdapter or FragmentStatePagerAdapter in order to easily embed RecyclerView. If you are going to update your ViewPager contents during its lifecycle it is strictly recommended to use FragmentStatePagerAdapter You will have to create additional fragment layout, containing RecyclerView. If you wish to update your ViewPager with...
There are a couple advantages of making a blank abstract class with no implementation in the methods. The first reason to make it abstract is you can't create the object itself. You always have to have a class that extends it which means you can't really accidentally create one. (Although...
java,android,recyclerview,custom-adapter
Here's a dynamic approach: Assuming you have your own adapter, turn it into an abstract class and create an abstract method called getDynamicView (this will not be your FrameLayout, but the layout you want to add to it). Your FrameLayout will be inflated as you create PostItemView object in your...
android,android-fragments,android-alertdialog,recyclerview
DialogFragment is just another Fragment, Inflate your custom view like you would do for any other fragment. public class MyDialogFragment extends DialogFragment { private RecyclerView mRecyclerView; private MyRecyclerAdapter adapter; // this method create view for your Dialog @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //inflate layout with...
I need to figure out the best way to determine if its already listed objects from the first object array (Object1) If position is bigger than (or equal to) the length of the first array, you are now into the second array. Subtract the length of the first array...
This below is a good example, take a look at it: public class DividerItemDecoration extends RecyclerView.ItemDecoration { private static final int[] ATTRS = new int[]{ android.R.attr.listDivider }; public static final int HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL; public static final int VERTICAL_LIST = LinearLayoutManager.VERTICAL; private Drawable mDivider; private int mOrientation; public DividerItemDecoration(Context context,...
android-layout,android-listview,recyclerview,android-4.1-jelly-bean
Finally found the solution! The problem lays in the layout XML file: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/list_item_doc" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:attr/selectableItemBackground" android:padding="12dp"> The background attribute apparenly isn't valid for Jelly Bean devices. Changing the value from android:background="?android:attr/selectableItemBackground" to...
Don't put your fixed header in the RecyclerView. Wrap the RecyclerView in a vertical LinearLayout, with your fixed header above it.
android,recyclerview,android-design-library,coordinator-layout
Try this code. You need to use app:layout_behavior in your RecyclerView <android.support.v7.widget.RecyclerView android:id="@+id/recyclerview" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"/> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginBottom="16dp" android:layout_marginEnd="16dp"...
android,animation,recyclerview,android-recyclerview,recycler-adapter
So i found the problem myself and fixed it :) For those who are having the same problem i will share my experience. I was calling mAdpter.notifyItemInserted(position) but it should be scaleAdapter.notifyItemInserted(position)....
android,adapter,onclicklistener,recyclerview,android-viewholder
thanks, but I solved the problem with setTag() and getTag() public class MyAdapter extends RecyclerView.Adapter { // some vars .... and a constructor @Override public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { View view = LayoutInflater.from(mContext).inflate(R.layout.recyclerview_item, viewGroup, false); return new ViewHolder(view); } @Override public void onBindViewHolder(final ViewHolder viewHolder, final int i)...
android,listener,recyclerview,get-childitem
Why don't you use the specific attach listener that the RecyclerView has: recyclerView.addOnChildAttachStateChangeListener(new RecyclerView .OnChildAttachStateChangeListener() { @Override public void onChildViewAttachedToWindow(View view) { } @Override public void onChildViewDetachedFromWindow(View view) { } }); ...
As the class name says it is all about recycling ... public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.RecViewHolder> { ArrayList<String> values; SparseBooleanArray expanded = new SparseBooleanArray(); public static class RecViewHolder extends RecyclerView.ViewHolder { //EDIT!!!!! public RecViewHolder (View itemView, final RecyclerViewAdapter adapter) { //rest of the code ... favHeaderLayout.setOnClickListener(new View.OnClickListener() { @Override public...
android,android-layout,recyclerview,android-cardview
See below edit, its logical mistake: RelativeLayout cardlayout = (RelativeLayout)itemView.findViewById(R.id.nativecardlayout); ...
android,recyclerview,android-cardview
it seem to that there is a typo mistake in your code, look at that, you have in your ViewHolder: public static TextView filmTitle; But then you work with it like with your other fields: @Override public void onBindViewHolder(final ViewHolder holder, int position) { // - get element from your...
I've found the answer myself. You need to put the LinearLayout into a ScrollView and use wrap_content as RecyclerView's layout_height. <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:fillViewport="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView android:layout_width="match_parent" android:layout_height="@dimen/list_header"...
android,android-layout,recyclerview,android-cardview,cardslib
Maybe because you set setContentView(R.layout.native_recyclerview_card_layout) but your CardRecyclerView is in cardslib_activity_recycler.xml ? Technically findViewById only finds view by id registered in the view hierarchy of the layout set by setContentView. If you want to combine views then you should use <include>....
android,android-studio,recyclerview
getAdapterPosition() is part of v22, of the support library, so the only way to use it, is to upgrade it. Here you can find the changelog
android,android-fragments,recyclerview,android-cardview
todo this you need to add the OnClickListener to your ViewHolder with an own Clicklistener, like this: new Interface: public interface PersonViewHolderClickListener { void onItemClick(long id); } and change your RVAdapter class like this: protected Context mContext; RVAdapter(Context context, List<Chapter> chapters) { mContext = context; this.chapters = chapters; } public...
nullpointerexception,fragment,recyclerview,android-recyclerview,recycler-adapter
The Nullpointer at r.set adapter(rA) occurs because r is null. The reason for r being null is that you tried to find the RecyclerView in the Fragment's parent Activity. But the RecyclerView is contained in the Fragment's layout, which you inflated in the onCreateView method and stored in v. So...
android,recyclerview,infinite-scroll,android-recyclerview
The problem is that when you add new item internal EndlessRecyclerOnScrollListener doesn't know about it and counters breaking. As a matter of fact answer with EndlessRecyclerOnScrollListener has some limitations and possible problems, e.g. if you load 1 item at a time it will not work. So here is an enhanced...
java,android,imageview,recyclerview,popupmenu
Luckily, I've just found the way to solve the problem: Use android.widget.PopupMenu not android.support.v7.widget.PopupMenu Replace final PopupMenu popupMenu = new PopupMenu(context, view); with final PopupMenu popupMenu = new PopupMenu(context, v); Honestly, I don't know why, just try it and voila!...
Initialize it when you add items to someList. Also, don't add click listener in your onBind, create it in onCreateViewHolder. You cannot use position in the click callback, instead you should be using ViewHolder#getAdapterPosition. See docs for details: https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html#onBindViewHolder(VH, int)...
android,xml,layout,recyclerview
Well finally, I got the solution for my question. In my RecyclerView adapter previously i used the below type of approach to create the list items public MyAdapter.ViewHolder onCreateViewHolder( ViewGroup parent, int viewType ) { // create a new view itemLayoutView = LayoutInflater.from( parent.getContext() ).inflate( R.layout.list_row_serch, null ); // create...
android,listview,textview,android-imageview,recyclerview
This happens because the views get recycled and reused. So when the view gets recycled, it retains properties of the "old" view if you don't change them again. So when you scroll down to number 12, the view that used to hold number 1 gets recycled (as it can't be...
the animation happens. But your old position zero becomes position 1 (visible on the screen) and the new position zero appears if you scroll up. So to make it visible you have to scroll the recycler afterwards. friendsList.remove(positionFriend); friendsList.add(0, newFriend); notifyItemInserted(0); notifyItemRemoved(positionFriend+1); recycler.scrollToPosition(0); ...
android,material-design,recyclerview
You can use a StateListDrawable to achieve the desired effect. Example Create a new Drawable resource file in your drawable directory with the following content: selector_row.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Color when the row is selected --> <item android:drawable="@android:color/darker_gray" android:state_pressed="false" android:state_selected="true" /> <!-- Standard background color --> <item...
you have to add "footer" at the end of your adapter. This footer will be just a blank view, like a android.widget.Space. recycler view doesn't have any native options for header n footers, but you can google around and find a few options. I developed a library with extras for...
This below is a good example, take a look at it: public class DividerItemDecoration extends RecyclerView.ItemDecoration { private static final int[] ATTRS = new int[]{ android.R.attr.listDivider }; public static final int HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL; public static final int VERTICAL_LIST = LinearLayoutManager.VERTICAL; private Drawable mDivider; private int mOrientation; public DividerItemDecoration(Context context,...
This works great for me: public void clearData() { int size = this.myList.size(); if (size > 0) { for (int i = 0; i < size; i++) { this.myList.remove(0); } this.notifyItemRangeRemoved(0, size); } } Source: https://github.com/mikepenz/LollipopShowcase/blob/master/app/src/main/java/com/mikepenz/lollipopshowcase/adapter/ApplicationAdapter.java For you: @Override protected void onRestart() { super.onRestart(); //first clear the recycler view so...
android,scroll,recyclerview,cancellation
I've figured it out. OnItemTouchListener should be used instead: onItemTouchListener = new OnItemTouchListener() { @Override public boolean onInterceptTouchEvent(final RecyclerView recyclerView, final MotionEvent e) { if(myCondition){ switch(e.getAction()){ case MotionEvent.ACTION_MOVE: return true; } } return false; } @Override public void onTouchEvent(final RecyclerView recyclerView, final MotionEvent e) { } }; Now you add...
android,android-fragments,recyclerview,android-cardview,recycler-adapter
notifyDataSetChanged should be used as a last resort, since it does not specify what has happened and therefore the adapter asumes nothing is valid anymore, which causes the list to not only rebind, but also relayout all visible views. You should instead use one of the notifyItem[Range][Inserted|Changed|Removed]() methods instead, in...
android,android-layout,android-fragments,views,recyclerview
Change mRecyclerView = (RecyclerView)getActivity().findViewById(R.id.circleList); to mRecyclerView = (RecyclerView)v.findViewById(R.id.circleList); ...
android,recyclerview,gridlayoutmanager
Well, you want alternate "rows" to be evenly split between two cells. Evenly split requires an even number of columns, and 3 is not an even number. So, change that to 2. Now, you want getSpanSize() to return (by row): position 0 = 2 (i.e., span both cells) positions 1...
Ok so I've found were the problem was. In my ViewHolder I had in addition to the layout Views, an ORMlite entity (could've been any object that was not part of the layout). The problem was that the ViewHolder's equals() and hashcode() methods were based on the entity which was...
android,nullpointerexception,recyclerview
Your ImageView id is iconImaVeView but in your code you are calling iconImaGeView. That's strange because you should have a compile error unless you have an iconImageView somewhere else in other .xml file.
android,android-layout,recyclerview
Set listener to your view in onCreateViewHolder ViewTreeObserver viewTreeObserver = view.getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { view.getViewTreeObserver().removeOnGlobalLayoutListener(this); viewWidth = view.getWidth(); viewHeight = view.getHeight(); } }); } Also check this and this question....
Finally I've been able to solve my problem by my teacher helped. what I have changed is I move the listener from onBindViewHolder to my ViewHolder class like this: public class StudentAdapter extends RecyclerView.Adapter<StudentAdapter.StudentViewHolder> { private LayoutInflater inflator; private int status; Typeface typeface; List<Student> students = Collections.emptyList(); public StudentAdapter(Context context,...
java,android,json,parse.com,recyclerview
here are the all things you should change.. first you are not getting all data of table(Object) flyerDataFetch, you are just getting the one specific column data with id "xWMyZ4YEGZ" your query should be ParseQuery<ParseObject> query = ParseQuery.getQuery("flyerDataFetch"); query.findInBackgroud(new FindCallBack<TableClass>(){ @Override public void done(ParseObject List<TableName> list, com.parse.ParseException e) { if...
android,recyclerview,listadapter,picasso,okhttp
The picasso instance being returned from PicassoBuilder.build() should be a singleton, and when you need to use picasso throughout the app you should be accessing that singleton, instead of Picasso.with... you should be accessing YourClass.getMyPicassoSingleton().with... Otherwise you're keeping separate caches, etc for those picasso instances edit: as I noted below,...
android,android-layout,recyclerview
You should implement a class which will be scrolled your recycler view. Note: this class must necessary working in UI thread. Something like that: mTimer = new Timer(); mMyTimerTask = new MyTimerTask(); // delay 1000 ms repeat in 1000ms mTimer.schedule(mMyTimerTask, 1000, 1000); RecyclerView recyclerView; float currentScrollY = 0; class MyTimerTask...
It turns out below algorithm is better private int previousTotal = 0; private boolean loading = true; private int visibleThreshold = 5; int firstVisibleItem, visibleItemCount, totalItemCount; mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); visibleItemCount = mRecyclerView.getChildCount(); totalItemCount = mLayoutManager.getItemCount(); firstVisibleItem =...
android,android-studio,gradle,android-support-library,recyclerview
I am not sure, How are you able to import it, But if you want to use RecyclerView, you need to add its dependency, i.e. compile 'com.android.support:recyclerview-v7:22.2.0' I don't see if you have added RecyclerView dependency to your gradle script. Also, keep in mind, it doesn't come with appcompat package....
You don't assign your List to anything. Change your constructor to assign your member variables as shown below. public myAdapter(Context ctx, List<Information> data) { inflater = LayoutInflater.from(ctx); this.data = data; } ...
android,animation,android-activity,recyclerview
According to the ItemAnimator documentation : This class defines the animations that take place on items as changes are made to the adapter. So unless you add your items one by one to your RecyclerView and refresh the view at each iteration, I don't think ItemAnimator is the solution to...
Your views are not inflated yet if they are not visible on screen As this answer has stated. The link also provides an interesting solution you can check. For your case you should track your models/objects inside on the adapters getView() and decide if it should be checked or not...
The problem is solved. It was with Adapter class where i played with the VISIBILITY. Thanx for the help
android,android-studio,recyclerview,android-recyclerview
You could represent the data fetched from your web service in an SQLite Database (a good tutorial on how to create/access sqlite databases in android can be found here: http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/). Then you could use a CursorLoader and a CursorAdapter for the RecyclerView and swap the cursor when the loader finishes....
android,json,recyclerview,recycler-adapter
give a call to notifyDataSetChanged() on Adapter after adding data to the list. if that doesn't work. try this change your constructor like this ... private ArrayList<Category> categoryArrayList; public CategoryAdapter(CategoryActivity activity, Context context,ArrayList<Category> categoryArrayList){ this.context = context; this.activity = activity; singleton = VolleySingleton.getsInstance(); imageLoader = singleton.getImageLoader(); this.categoryArrayList = categoryArrayList; }...