Writing code at the creation of a fragment

All the examples I’ve seen so far for dealing with programmatically handling things from a view have involved an activity and the layout associated with it. But when I am working with Android Studio, whenever I create a new activity things are a little different and I get two layouts and things are happening in a fragment rather than the first layout. I don’t totally get the whole thing yet, I’m working on wrapping my mind around it. But today I did figure out something that was really giving me fits and I want to document it for later.

I wanted to start a new activity and in the view for that activity display a chart using the Android GraphView. Jonas provides nice documentation with example code on how to do this. But the fragment thing was really messing me up. I couldn’t figure out where to put the code and how to get it to work. The example I was interested in looks like this:

But I would put it in different places and crash the app or get compiler errors before I even started. I did a lot of searching and reading before I got it to work and I guess I don’t need to rehash all that. It was the accepted answer on this stackoverflow question that finally put the last piece in place for me though.

When I create a new activity the class for it has a class inside that creates the fragment:

This made sense as the place to do my work but I couldn’t figure out how. I had trouble trying to reference the view. But it was right in front of me the whole time. Here is what finally worked.

Oh – here’s the xml for the layout. I don’t think it matters a whole lot – but this is where the graphM id is located.

I was so happy when I ran this and I saw my graph pop up rather than the error message from the app crashing. It was a banner moment in my day.

Tagged with: , , ,
Posted in Geeks In Action, java, Programming

New Clothes

I haven’t spent time here in quite a while. The old theme had become broken. I don’t have time to mess with it now – but I switched to the responsive theme, which I like and I’ll get to cleaning it up later. Too busy now.

Posted in Geeks In Action, Themes, WordPress

Setting Up My AndroidStudio Project on GitHub

I started a project to do my homework for the week in the Android class I’m taking. I’ve been doing the bulk of my work on a desktop machine in my office. This week-end I also set up a dev environment on my Fedora laptop at home. I don’t want to have to monkey with copying files and carrying them back and forth so today I set up a GitHub repo so that I could use it to keep things in sync.

I’m no git expert. In the past what I’ve done is create a project in github with a couple pieces in place. Then I pull that down to a directory on my machine, add the files I need and then push all that back up.

Today I took a little bit of a different approach. I created the project. Then in bash I went to the root directory of the project and set things up. It took me a minute to get it all figured out. The git reference on remotes was a huge help. There is also the JetBrains documentation on git with IntelliJ which is what Android studio is built on.

For my own reference – once I got the project built I needed to add everything. First I went to github and made a repo – but I made it empty, not like I usually do. Then I went to the root of my project in bash.

and then make an initial commit

I set up the remote

(bittercode is my github user name and learnandplay is the name of the repo I set up.)

Then I pushed the code to the remote

And that put it all up at github. Now I should be able to go home and pull it all down there. I also set up AndroidStudio so that it now handles all the git stuff. When I created a new activity it asked me about adding them to git – so I just said that it should default to yes and now I’m on the fast track to happy days.

Tagged with: , ,
Posted in Geeks In Action, Programming

It’s like rai-eeeeee-aiiin on a sunny day

Signed up for the webcast of an OSCON talk today. When I registered I noticed a littel link in the corner that said, “Test Your System”. So I did. The results are below.

Results of test on my Fedora 19 box.

Results of test on my Fedora 19 box.

It struck me as a tad ironic that Fedora 19 is viewed as an OS that fails the test to view content from a conference about open source software.

Tagged with:
Posted in Linux, OS

Fedora 18, Nouveau Drivers and Firefox

I’ve got a desktop that I use as my primary work machine. It runs Fedora 18 and drives 2 monitors via an old but serviceable GeForce card.

Unfortunately what that means is I’ve got to live in a world of crappy compromises. It took me quite a while just to get things working. I started with the Nouveau drivers. The problem is that even with all desktop effects turned off – the display starts developing little “artifacts” over time. Or if I want to make the entire desktop completely unusable I just need to start Firefox and visit a page or two. In fact, oddly enough, the Google Sites that Sophie Schmidt made about her trip to North Korea, opened in Firefox will completely trash my whole desktop.

Everything that pops up from here on out is a mess and closing stuff wont help.

Everything that pops up from here on out is a mess and closing stuff wont help.

It took a while but I got the nVidia drivers to work. Well, that’s not honest. I found JR’s Fedora 18 nVidia Drivers Install / Uninstall Guide and he had figured how to get it to work. I followed the instructions and I was in hog heaven. Firefox worked and I could enable desktop effects for some nice eye candy. I’ve been happily cranking along since.

Then last week a co-worker in the US sent me a google hangout invite and when I went to answer it KDE crashed. This made me sad. I immediately thought of the drivers but tried many other avenues of curing the issue, in the hopes that it was something else. But no. I uninstalled all the nVidia stuff and went back to Nouveau. Hangouts works again and I can’t use Firefox any more.

I really need Hangouts. I wish I didn’t. Well, what I really wished is that all my sofware worked well with the Nouveau drivers or that it all worked with the nVidia drivers. Either one would be acceptable.

The up side I guess is that I don’t have a ‘tainted’ kernel any more.

Tagged with: ,
Posted in Geeks In Action, Linux

Goodbye Outlook

I removed my shortcut to Outlook from my taskbar on my Windows machine today. It felt really good.

Our organization, Cru, is in the process of moving from Exchange to google apps. The list of reasons I need a computer running windows just got shorter. I think I’m down to 2 programs I still need that are win only and we may see changes that will make it possible to leave those behind as well soon. Then again – there is Netflix. Ah well – I may have one windows machine for a while but not needing it to get my full email client is super nice.

This also makes picking up a little chrome book much more doable. They are cheap enough that it might make sense just for taking to meetings. If I get more out of it, that’s all bonus.

Well – that’s it. Big day.

Tagged with:
Posted in Geeks In Action, Google

Gimp on KDE Problem

I’m a Fedora user as I’ve mentioned before. I do not run the default de, gnome though. I’m a KDE user. I recently moved my main work machine to Fedora 18. I had a bump or two but I’ve gotten things mostly dialed in. Today I tried to use the Gimp to do some work on an image but it would not start. I tried from the launcher first and that failed. I moved to the console and was greeted by an immediate segfault.

These attempts kicked off the Automatic Bug Reporting Tool (ABRT) and so I decided I should let it send in a report. It did it’s thing and informed me that the bug had already been reported with a link to this bug. This was rather nice.

I looked at the bug report and saw that this is an issue dealing with the theme KDE was using for GTK+ apps. Well – I’m just using the defaults and didn’t even know where to look to change this so I googled. The answer is to go to System Settings -> Application Appearance (not Workplace Appearance) -> GTK+ Appearance. On the page there I had a few choices for Widget style. For now I’ve chosen Adwaita. I’ll keep an eye on this bug and switch back when it gets fixed.

So if you are a KDE user and Gimp wont start – there you go – that should fix it.

Tagged with: , , ,
Posted in Geeks In Action

Translate This Page

EnglishFrenchGermanItalianPortugueseRussianSpanish

Search the Bible


Archives

July 2014
M T W T F S S
« Jan    
 123456
78910111213
14151617181920
21222324252627
28293031