How to add a custom button state

The solution indicated by @(Ted Hopp) works, but needs a little correction: in the selector, the item states need an “app:” prefix, otherwise the inflater won’t recognise the namespace correctly, and will fail silently; at least this is what happens to me. Allow me to report here the whole solution, with some more details: First, … Read more

How to save RecyclerView’s scroll position using RecyclerView.State?

Update Starting from recyclerview:1.2.0-alpha02 release StateRestorationPolicy has been introduced. It could be a better approach to the given problem. This topic has been covered on android developers medium article. Also, @rubén-viguera shared more details in the answer below. https://stackoverflow.com/a/61609823/892500 Old answer If you are using LinearLayoutManager, it comes with pre-built save api linearLayoutManagerInstance.onSaveInstanceState() and restore … Read more

AngularJS ui router passing data between states without URL

We can use params, new feature of the UI-Router: API Reference / ui.router.state / $stateProvider params A map which optionally configures parameters declared in the url, or defines additional non-url parameters. For each parameter being configured, add a configuration object keyed to the name of the parameter. See the part: “…or defines additional non-url parameters…” … Read more

How to prevent custom views from losing state across screen orientation changes

I think this is a much simpler version. Bundle is a built-in type which implements Parcelable public class CustomView extends View { private int stuff; // stuff @Override public Parcelable onSaveInstanceState() { Bundle bundle = new Bundle(); bundle.putParcelable(“superState”, super.onSaveInstanceState()); bundle.putInt(“stuff”, this.stuff); // … save stuff return bundle; } @Override public void onRestoreInstanceState(Parcelable state) { if … Read more