Throw an idea please. There are 3 pages, each page has a list of 10 lines. If you click on the list, it will change color to red.

How can you save it so that after rebooting the phone, or restarting the program, it was all visible?

The answer is supposedly: "To use the database" is not appropriate, because from this the implementation of these actions will not be clear to me. The fact that you can store the info in the database I know, but how will it all work?

  • one
    @Futurama, According to the rules of the forum, questions should not be limited to the decision or the completion of student assignments. Please clarify what you have done yourself and what did not work out. - Vladyslav Matviienko
  • 2
    Use DB. This answer is appropriate . If you do not know how to use the database, ask just that. - Vladyslav Matviienko
  • 3
    And stop tagging your stupid questions with the java-ee tag. He has nothing to do with her. - Vladyslav Matviienko
  • 2
    @Futurama And how does this question relate to the android-studio development environment ? By sabzh - what exactly is not clear? While reading information from the database, you set the color ... I do not even understand your problem. A piece of code chtoli show - arg
  • 2
    Yes schA, Barmaley come, ruin everything. - arg

1 answer 1

You're bad. The architecture is bad. The solutions are bad. I can not look at your code and your vain attempts to invent another bike. I'll just show you how I did when I wrote my one program for Android. This scheme should give an approximate idea of ​​how to recover after the screen turns or closes. I want to note that the preferences object is filled with values ​​completely in other places, and not in the call-back methods. For example, I have a special activit in which I expose a bunch of settings as the size / color of the brush shape.

@Override protected void onCreate(Bundle in) { super.onCreate(in); if (in != null) { // этот блок выполняется когда произошёл поворот Activity. // Восстанавливаем из Bundle }else { // выполняется когда запущено первый раз. считывание из Preferences } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); application.saveStack(undoStack); application.saveBitmap(editableBitmap); writePaintBrushToBundle(paintBrush, outState); writePaintTextToBundle(paintText, outState); } public static void writePaintTextToBundle(Paint p, Bundle bundle) { bundle.putInt(PAINT_TEXT_COLOR_KEY, p.getColor()); bundle.putFloat(PAINT_TEXT_SIZE_KEY, p.getTextSize()); } public static Paint readPaintTextFromBundle(Bundle bundle) { Paint p = new Paint(); int color = bundle.getInt(PAINT_TEXT_COLOR_KEY, DEFAULT_PAINT_TEXT_COLOR); float textSize = bundle.getFloat(PAINT_TEXT_SIZE_KEY, DEFAULT_PAINT_TEXT_SIZE); p.setColor(color); p.setTextSize(textSize); return p; } 

This should roughly clarify how you should work with the Bundle and Preferences. If it is still not clear - I can post the full code of my activation. It is large (it was written a long time ago, along with anti-patterns), but I can point out methods that should be noted.

  • @argamidon, if it were oncreate, there would be no trouble, but I do it in the ListView, which, like an infection, is updated every time, deletes, updates, adds, deletes, and it needs a static array where it is indicated that in this position it will be + in this minus and not as a suit, what did you write? What do you want me to do in getView? so that he a thousand times the preferences caused? So that the teleofn from such a program burned down, Your architecture is much worse than mine. - Futurama
  • four
    @Futurama Preferences also needs to be able to use. And do not call every time "when I want." In my program, I read the Preferences once - I initialize the fields and that's it. And when I need, I turn to the fields . Can't you do the same in your program? - arg