Mark M. | has entered the room |
Mark M. | turned on guest access |
RP | has entered the room |
Mark M. |
hello, RP~
|
Mark M. |
er, RP!
|
IpiRon | has entered the room |
Mark M. |
how can I help you today?
|
IpiRon |
View paste
(27 more lines)
|
RP |
Hi Mark
|
MyWay | has entered the room |
Mark M. |
(IpiRon -- RP beat you by a few seconds, so I'll take a question from him first)
|
RP |
I have a quick quesiton about ActionBar
|
MyWay |
Hello (today I'm here just reading :P)
|
Mark M. |
(MyWay: OK -- let me know if you come up with a question)
|
Mark M. |
RP: go ahead
|
RP |
I'm fairly new to Android programming and am trying to customize the action bar - also looked at your sample...
|
Oct 13 | 4:00 PM |
RP |
However I'm getting a null object when I use getActionBar(). Cannot see why this should be happening. Any ideas on what I should be looking at.
|
Mark M. |
are you inheriting from Activity, AppCompatActivity, or something else?
|
RP |
I'm calling it in my main activity - very similar to how it is done in your sample.
|
Mark M. |
is your Java class inheriting from Activity, AppCompatActivity, or something else?
|
RP |
No - could that be the issue?
|
Mark M. |
then your code cannot even compile
|
RP |
OKay then maybe that's not the case. Here is the code snippet......
|
Mark M. |
and I have no means of helping you
|
RP |
View paste
(2 more lines)
|
Mark M. |
if you look at the first line of what you pasted in, you will see that SuperHeatCalc extends ActionBarActivity
|
Oct 13 | 4:05 PM |
RP |
Yes sorry I got confused there
|
Mark M. |
OK
|
Mark M. |
replace getActionBar() with getSupportActionBar()
|
Mark M. |
you are using the appcompat-v7 action bar backport
|
Mark M. |
and so you use getSupportActionBar(), as getActionBar() will return null
|
RP |
Okay I will try that. So it is to do with the library I'm using.
|
Mark M. |
if "the library" is appcompat-v7, then yes
|
Mark M. |
let me take IpiRon's question, then I'll be back with you in a bit
|
RP |
Okay great I will try that.
|
RP |
ok
|
Mark M. |
IpiRon: from your paste, one of your three files in res/values/ should also have a red X on it -- which one is it?
|
IpiRon |
just the res/values has the red x
|
IpiRon |
only the folder has it, no files in it have a red x
|
Mark M. |
if you use your OS' file explorer to look in res/values/, are there any files other than the three that you listed in there?
|
IpiRon |
no, only those files are in there
|
Mark M. |
then I have no explanation to offer you for your problem
|
Mark M. |
I do not recall seeing that behavior when I last used Eclipse
|
IpiRon |
okay, I'll play with it a bit more and stay on the line here
|
Mark M. |
and that was over a year ago
|
Oct 13 | 4:10 PM |
Mark M. |
you might check the, um, Errors(?) window, or whatever it was called in Eclipse, to see if there are messages there of possible relevance
|
Mark M. |
if you are set up to do command-line builds, try one of those, and see if you get better error information
|
Mark M. |
and if you are not set up to do command-line builds, grab Gradle and use it to build your project (you don't need to change the project structure to do this, though you'll need to craft a build.gradle that handles the Eclipse-style project structure)
|
IpiRon |
Errors shows nothing. I even tried LINT but nothing there...
|
Mark M. |
let me take a question from RP, and I'll swing back to you in a bit
|
IpiRon |
okay
|
Mark M. |
RP: your turn! do you have another question?
|
RP |
No that's all and what you suggested works so thanks for your help today.
|
Mark M. |
OK, glad to hear that you got it going!
|
RP |
thanks
|
Mark M. |
you'll find more about appcompat-v7, and its differences from the native action bar, in the book's chapter on AppCompat
|
Mark M. |
if you come up with another question, let me know, so I can switch over to you
|
Mark M. |
IpiRon: back to you! do you have another question?
|
RP |
OKay I will check it out. I really like your book but there is so much content to cover
|
IpiRon |
Not at present, I'll hop off and reconnect if I do.
|
Mark M. |
OK
|
IpiRon | has left the room |
Mark M. |
if anyone comes up with a question, chime in!
|
RP |
Okay since I'm here maybe I'll ask another one
|
Mark M. |
go right ahead!
|
RP |
SO after the changes I just made I was expecting to see the app icon in the action bar but it's not there. Any ideas why?
|
Oct 13 | 4:15 PM |
Mark M. |
appcompat-v7 gives you a backport not only of the action bar, but of the "Material Design" aesthetic
|
Mark M. |
under Material Design, there is no app icon in the action bar
|
Mark M. |
you will get the same thing if you used the native Theme.Material on Android 5.0+
|
RP |
SO is there a way to achieve this. DO I need to change the theme. Not really got to that section yet in your book
|
Mark M. |
if by "achieve this", you mean put the icon in the action bar, you really can't do that with AppCompat
|
Mark M. |
(there's a way, but the icon comes out the wrong size, and it looks *awful*)
|
Mark M. |
(and it's not really supported anyway)
|
Mark M. |
you're welcome to switch over to the native action bar
|
Mark M. |
if you are using Theme.Holo (and child themes), you will get an icon in the actoin bar
|
Mark M. |
er, action bar
|
Mark M. |
however, you'll still lose the icon on Android 5.0, if you use the native theme for that version of Android (Theme.Material)
|
RP |
Yes that's what I meant. Thanks for clarifying. I guess more reading to get a better understanding of what's going on.
|
Mark M. |
you could say that you are going to use Theme.Holo for Android 5.0+ too, though your app will look somewhat out of place
|
Mark M. |
the biggest limitation of switching off of AppCompat is backwards compatibility
|
Mark M. |
the native action bar only showed up with API Level 11
|
Mark M. |
if you are trying to support Android 2.x devices, you won't have an action bar unless you use AppCompat
|
Oct 13 | 4:20 PM |
Mark M. |
though, since Android 2.x is below 10% market share on the Play Store, most new development is dropping support for those devices anyway
|
RP |
I'm not planning on supporting 2.x and below. The app has been undergoing alpha testing on play and so far no complaints.
|
Mark M. |
if you are that far along, I would just not worry about the icon, then
|
RP |
Yes I just thought it would look nice - not a major hurdle for getting the app released.
|
Oct 13 | 4:25 PM |
RP |
Okay thanks Mark - I guess that wraps it up for me.
|
Mark M. |
OK
|
RP | has left the room |
IpiRon | has entered the room |
IpiRon |
(hello again)
|
Mark M. |
hi!
|
Mark M. |
if you have a question, go right ahead!
|
IpiRon |
okay..
|
IpiRon |
The problem with my red X on the values folder was some sort of SVN conflict. I restored from SVN and the X went away!
|
Mark M. |
OK -- I never tried SVN integration with Eclipse, let alone on an Android project, so I don't have much explanation there
|
IpiRon |
Just in case you run into this... Thanks for the 'ear'
|
Oct 13 | 4:30 PM |
IpiRon |
No problem. I'm signing off!
|
Mark M. |
thanks for the info!
|
IpiRon | has left the room |
Oct 13 | 4:35 PM |
MyWay |
do you know anything about Kotlin, Mark?
|
Mark M. |
I don't even quite know how to pronounce "Kotlin"
|
Mark M. |
though I'm guessing its a short "o"
|
MyWay |
I have no idea
|
Mark M. |
:-)
|
MyWay |
eheh
|
Mark M. |
beyond that, not really
|
MyWay | |
MyWay |
it seems interesting
|
Mark M. |
yes, every 2-3 years, somebody comes along and says that X is the new language to do stuff on the JVM
|
Mark M. |
Scala, Clojure, JRuby, etc.
|
MyWay |
ahah
|
MyWay |
that's true, too
|
Mark M. |
they all gain some niche uses, but fail to gain widespread traction
|
Oct 13 | 4:40 PM |
Mark M. |
so, while there's nothing wrong with Kotlin in all likelihood, I'm not exactly racing out to spend time on it
|
MyWay |
yes
|
MyWay |
this seems reasonable
|
Oct 13 | 4:50 PM |
MyWay |
have a nice day Mark, thank you :)
|
Mark M. |
um, you're welcome, for whatever I did :-)
|
Oct 13 | 5:00 PM |
Mark M. |
that's a wrap for today's chat
|
Mark M. |
the transcript will be posted to https://commonsware.com/office-hours/ shortly
|
Mark M. |
the next chat is Thursday at 9am US Eastern
|
Mark M. |
have a pleasant day!
|
MyWay | has left the room |
Mark M. | turned off guest access |