This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!

Mike Gosling

Ranch Hand
+ Follow
since May 19, 2016
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mike Gosling

I give up on GridLayout. I actually used this guy's tutorila on Linear Layout. Super cool idea to nest linear layouts.

5 days ago
It means that that ( and ) keep using too much space and eventually the / sign gets pushed out from the screen. I don't know how to make ( and ) take 1/2 of their original width, so I could accommodate their width in cell.

Turns out, according to some SO posts, that GridLayout is not meant for this kind of action. As Tim suggested, I also tried with Linear Layout. I'm getting similar results.

Again, as with TableLayout, both ( and ) takes too much of space. They in total should take as much now one button takes place. Division sign gets push out.

Should I try to do this design in LinearLayout (horizonatl) only?
5 days ago
I tried with that one as well. No way to get it nearly as I want.

5 days ago
I have this super complicated design in the attachment. I would like to fit left and right parenthesis in single cell (row 1, col 1) so they occupy 1/2 of the cell for each button. I have following xml

5 days ago
I checked the docs.

Now I have code like this:

Menu resource xml:


This solved the problem.

Maybe Tim Moores can suggest some up to date book for us CS students newbies in Android

P.S. For anyone who is reading Head First Android Development:

After fixing ShareActionProvider, if you are following the book, you're most probabbly going to get NullPointerException in OrderActivity. If you have this code, like in the book:

This is going to get you NullPointer.

I just did this, reading from docs and SO, and its doing what the author wanted us to achieve:

1 week ago
Thank you Tim for helping.

At the moment this is what I have in menu_resource xml file (the part that is relevant):

And this is in activity code:

Line 14 is underlined with red, saying: Inconvertible types: cannot cast android.view.ActionProvider to androidx.appcompat.widget.ShareActionProvider;

How does Android with getActionProvider() is trying to obtain ActionProvider from android.view.ActionProvider, in both cases, when I used android.widget.ShareActionProvider and now with androidx.appcompat.widget.ShareActionProvider?
1 week ago
I was looking on the docs and couldn't find anything. They are also using same import or

but AndroidStudio reports an error on v7. It marks it red.

So frustrating...
1 week ago
I have activity with following import and code:

In menu resource xml file, I'm trying to define share action provider:

As you can see I'm using the same import package in menu resource file and in the activity (android.widget.ShareActionProvider).  But for some reason I always get ClassCastException:

Im following Head First Android Development, but this books is from 2015. Some things must have certainly changed since. Or am I making some stupid import mistake?
1 week ago
Damn, my bad! In activity I referenced TextView component with an id "time_view", while that same component has in xml file id of "text_view".
1 week ago
Do you mean Event Log? I'm new to Android Studio, so everything is mixed up right now

Here is what I got from Event Log:

1 week ago
I apologize if there's already a thread with this or similar problem I'm currently facing. I just couldn't find it.

I'm trying to simulate simple Stopwatch app, from Head First Android Development book.

I am not sure why I'm getting info that app has stopped working.

Here is the activity code:

And here is layout code:

Everything is the same as in the book, but I keep getting "App has stopped working".
1 week ago

Liutauras Vilda wrote:Seem to be very weak arguments to use it. Hard to notice any actually. By the way, Lombok generates code at compile time, not runtime as the book suggests. I would recommend to forget this library in Java ecosystem and avoid using it.

Thank you for giving better clarification. Tho, I'm not using Lombok for the sake of Lombok, rather to follow up the author. It seems that he uses Lombok throughout the book.
1 week ago
I'll just give you big quote from the book:

As you can see, this is a run-of-the-mill Java domain class, defining the three properties needed to describe an ingredient. Perhaps the most unusual thing about the Ingredient class as defined above is that it seems to be missing the usual set of getter and setter methods, not to mention useful methods like equals(), hashCode(), toString(), and others. You don’t see them in the listing partly to save space, but also because you’re using an amazing library called Lombok to automatically generate those methods at runtime. In fact, the @Data annotation at the class level is provided by Lombok and tells Lombok to generate all of those missing methods as well as a constructor that accepts all final properties as arguments. By using Lombok, you can keep the code for Ingredient slim and trim.

Lombok isn’t a Spring library, but it’s so incredibly useful that I find it hard to develop without it. And it’s a lifesaver when I need to keep code examples in a book short and sweet.
1 week ago
Damn, it is working now! Thank you Salivn Francis. One small thing, STS is saying that <version> is not required in pom.xml.

I'll make sure to follow the forum rule you pointed out.

Thank you one more time.

P.S. If anyone in future stumbles on similar problem and is reading this, and links here are broken, fell free to PM me and if I know, I'll help.
1 week ago
Thank you salvin francis for replying.

salvin francis wrote: The eclipse.ini or sts.ini should contain:


This is the content of my SpringToolsSuite4.ini (i thnik that is sts.ini) file.

When I go to look for lombok.jar in m2 folder. This is how I do:

and this is the content of the destination folder.

Once I type this command in cmd (after positioning in the location above):

I get Installation wizard, like this.

Assuming I need to specify location for SpringToolSuite4, I do so by selecting installation folder where STS is located. This is how it looks like. This is final look on wizard before hitting Install/Update button.

If I go back again to folder where STS is installed (unzipped), this is how it looks like. Jar lombok is present. New content of .ini file, now, I have that line you mentioned in your post. I am not sure if that is correct.

Once start STS again, it complains that it doesn't see lombok.

1 week ago