This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyView extends View { | |
private static class SavedState extends BaseSavedState { | |
String name; | |
int index; | |
SavedState(Parcelable superState) { | |
super(superState); | |
} | |
private SavedState(Parcel in) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyView extends View { | |
private static class SavedState extends BaseSavedState { | |
// TODO: | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyView extends View { | |
public MyView(Context context) { | |
setSaveEnabled(true); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SomeActivity extends Activity { | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.some_layout); | |
MyView myView = new MyView(this); | |
myView.setId(R.id.desired_id); | |
addView(myView); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<MyView | |
android:id="@+id/desired_id" | |
... | |
/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void dispatchSaveInstanceState(SparseArray<Parcelable> container) { | |
// Create a SparseArray just for us! | |
SparseArray mySparseArray = new SparseArray(mChildrenCount + 1); // +1 for our ViewGroup's state. | |
// Repeat the normal logic for this method, but pass our "mySparseArray" instead of "container" | |
super.dispatchSaveInstanceState(mySparseArray); | |
final int count = mChildrenCount; | |
final View[] children = mChildren; | |
for (int i = 0; i < count; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void dispatchSaveInstanceState(SparseArray<Parcelable> container) { | |
super.dispatchSaveInstanceState(container); | |
final int count = mChildrenCount; | |
final View[] children = mChildren; | |
for (int i = 0; i < count; i++) { | |
View c = children[i]; | |
if ((c.mViewFlags & PARENT_SAVE_DISABLED_MASK) != PARENT_SAVE_DISABLED) { | |
c.dispatchSaveInstanceState(container); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This example assumes that the developer is using the new Android embedding | |
// API, some plugins that use dart-side initialization, and some old plugins | |
// that have no concept of dart-side initialization. | |
// | |
// This example would be the same even if all used plugins were old (no dart-side | |
// initialization). | |
public class MainActivity extends FlutterActivity { | |
@Override | |
protected void onFlutterEngineCreated(@NonNull FlutterEngine engine) { | |
// We register the GeneratedPluginLoader for the plugins that use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This example assumes that the developer is using the new Android embedding | |
// API, as well as plugins that have opted-in to the proposed dart-side | |
// plugin initialization. | |
public class MainActivity extends FlutterActivity { | |
@Override | |
protected void onFlutterEngineCreated(@NonNull FlutterEngine engine) { | |
engine.setPluginLoader(new GeneratedPluginLoader()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MaterialApp( | |
theme: ThemeData( | |
brightness: Brightness.light, | |
primaryColor: Colors.red, | |
), | |
darkTheme: ThemeData( | |
brightness: Brightness.dark, | |
), | |
); |