Save background and text to a database

Asked

Viewed 56 times

0

My project is simple, a grid view, with several buttons, and at the click of them opens a popup with 3 options and at the click of them, arrow a text and a background on the button, but when I leave Activity and enter they , are not there, wanted a help with database, to save it.

botaoDoGridView.setOnClickListener(new View.OnClickListener() {@Override
    public void onClick(View v) {
        final PopupMenu pn = new PopupMenu(CalendarActivity.this, bt11);
        pn.getMenuInflater().inflate(R.menu.popup_menu, pn.getMenu());
        pn.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {@Override
            public boolean onMenuItemClick(MenuItem item) {
                switch (item.getItemId()) {
                case R.id.primeiro:
                    bt11.setText("HIDRATAR");
                    bt11.setBackground(getDrawable(R.drawable.fundohidra));

                    return true;
                case R.id.segundo:
                    bt11.setText("NUTRIÇÃO");
                    bt11.setBackground(getDrawable(R.drawable.fundonutri));
                    return true;
                case R.id.terceiro:
                    bt11.setText("RECONS");
                    bt11.setBackground(getDrawable(R.drawable.fundorecon));
                    return true;
                case R.id.quarto:
                    bt11.setBackground(getDrawable(R.drawable.desligar));
                    Toast.makeText(CalendarActivity.this, "Etapa Finalizada,Aguarde entre 48 a 72 horas para ir pra proxima Etapa", Toast.LENGTH_LONG).show();
                    return true;
                }

                return true;
            }
        });
        pn.show();

    }
});
  • Read on in that page

  • really sorry bro... I didn’t know that, I already switched

  • Good, one tip: put 4 spaces in front of your code to make it better formatted

  • vlw mano <3 , I will publish the app in a few days, and this is the last step, I need help kkk , just save this background and text of the boot ,for when you leave Activity and enter they aind are there

  • Dude, the implementation of a bank is not so trivial as to stick to an answer. It gives a studied, not complicated, and remakes the question get stuck somewhere during implementation. If your gridview is not very dynamic (enter and exit item all the time), you can save button options in Sharedpreferences, which is a much simpler implementation

  • Since there are few dice and something basic, why don’t you save that in a SharedPreferences ? Will persist in the same way.

  • I tried for right now in Shared and gave fail , kkk first try lose..

  • Luan Abriel , has contact by Whats app? some group ?

  • @Clehsilvah gives a look at the new architecture of Android, got very good and fast to work with data persistence. Class Room https://developer.android.com/topic/libraries/architecture/room.html

  • send Whats app number ???

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.