Click here to Skip to main content
15,881,516 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How do I add Favourite button to project, so whenever someone click on it ,it get saved and they check on right-side panel.

My Project Is: Weather App
Building using Javascript

What I have tried:

I'm working on and finding solutions to the problems that I face in my current role.

I have been able to find ways to improve the quality of my work, and also to do more with less.
Posted
Updated 17-Jul-22 1:44am
Comments
Richard MacCutchan 5-Jul-22 9:53am    
At a guess, you add a button element to your HTML, and some code to handle its onclick event.
SashaGamer 1993 17-Jul-22 7:30am    
You can put it in your Favourite section with CSS, you can search and find it on youtube.
but you can make a button like this:
Test
and you need to give your button a class like this:
Test
and in CSS you can do this:
.button{
position: absolute;
text-align: center;
}

Remember this CSS code is for placing the button in the center, if you have any questions ask me!

Thanks for the answers, but if I have to also put it in the Favourite section how can I do that
 
Share this answer
 
Comments
Richard MacCutchan 6-Jul-22 7:34am    
No one here has any idea what your project is doing, or how it is structured, so we cannot possibly answer such a vague question. Please read https://www.codeproject.com/KB/FAQs/QuickAnswersFAQ.aspx[^].
ou always put a fixed background to your favouriteToggleButton, you need to read your SharedPreferences State value and set a background to your favouriteToggleButton, just add these lines to your activity

  @Override
    protected void onResume() {
        super.onResume();
        if (! readstate()) {
            favouriteToggleButton.setBackgroundDrawable(ContextCompat.getDrawable(getApplicationContext(),R.drawable.ic_favorite_border_black_24dp));
        }
        else {
            favouriteToggleButton.setBackgroundDrawable(ContextCompat.getDrawable(getApplicationContext(),R.drawable.ic_favorite_black_24dp));
        }
 
Share this answer
 
Hello! you can put your button in your Favourite section with CSS, if you want to do that you need to search on youtube. but here is an example for it:

if you want to make a button, you need to do this in HTML:
<button>Test</button>

and then give it a class like this:
<button class="button">Test</button>

for the CSS, you need to link your CSS file in HTML, to do that , do this in the HTML head part:
<link rel="stylesheet" href="your CSS file name.css">

and then in the CSS part, do this:
.button{position: absolute;
    align-items: center;}

or do this:
.button{
position: absolute;
text-align: center;}

remember this is just for placing the button in the center, if you have any questions ask me! and if I did't respond ask me in discord : SashaGamer#3271
 
Share this answer
 
Comments
Dave Kreskowiak 17-Jul-22 12:51pm    
None of that puts the site URL in the browsers Favorites or Bookmarks collection.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900