Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Android Tutorial & Lessons 15: Program our RadioGroup to change style and gravity

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
21,214
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Feb 2, 2011

Android Tutorial & Lessons 15: Program our RadioGroup to change style and gravity

Whats up CornFanz, thanks for watching my videos, I would love it if you subscribe and give me some feedback.

In this lesson you will:
-learn to program our radio groups
-set up the OnCheckChangedListener
-learn to set our text's style & gravity
-Some other sweet stuff
-subscribe
-Thumbs up this video ;)

This video is the 15th in a web series that I am creating to help you learn Android programming so you can create apps and eventually how to learn to write games for android phones. I want to explain things in a way that everyone can understand, even if you have no experience with Java, XML, C++, OpenGL, or as a matter of fact, any other programming language.




If you do have a lot of experience with programming, these first videos will be really slow for you, but my goal is to get everyone sprinting, but for now we have learn to crawl.

follow me on twitter: @cornboyz

  • likes, 2 dislikes

Link to this comment:

Share to:

Uploader Comments (CornboyzAndroid)

  • Travis.. Assume the Left "Gravity" radio button and Normal "Style" radio button are both initially check (ie, android:checked="true") in the layout setup. How does the "switch" logic recognize both initially checked buttons in tutorialOne.java when the first checked button causes the system to "break"? The reason I ask is because I like to initialize all radio group buttons when a screen is first presented to a user.

  • @dutch345 they way we set it up wouldn't recognize it. if however you want to set up an initial selection you could set it up the variable that changes within the onCreate method. for example you could set up textOut.setGravity(Gravity.CEN­TER); within the onCreate method if you initialize the center radio button checked to true. That's a basic way to accomplish what you are looking for

  • Hi!

    Nice tuts. But u got some confusion about the "this" and "implements".

    The "this" in this case is pointing to the actual class tutorialOne. (like you could type this.textOut and it would work)

    Since you set tutorialOne as a listener, it have to implement the oncheckedchangelistener interface wich is a litlebit different than a class.

    The main difference is that when u implement from an interface you have to implement its methotds, in this case onCheckedChange(RadioGroup goup,int checkedId).

  • @themobius Hey man, Thanks for the input!

see all

All Comments (18)

Sign In or Sign Up now to post a comment!
  • Thanks, man! You are awesome! You are really explaining it, so that everybody can understand! Thumbs up!

  • Just from watching your videos, I have ascended. You are the master.

  • many thanks bro, keep going.

  • Thanks for these supporting vedios, but by some reason

    textOut.setGravity(Gravity.LEF­T);

    textOut.setTypeface(Typeface.d­efaultFromStyle(Typeface.NORMA­L));

    are not responding but this is responsing..

    textOut.setText("Center");

    Again thanks for these vedios...

  • Hmm you can just add null argument on style, I mean typeface.

    So you don't need to add Typeface.defaultFromStyle. Also don't need at the end ,Typeface.ITALIC again. Work perfect just with first parameter null.

    Probably like this:

    textOut.setTypeface(null, Typeface.ITALIC);

    and for others

    textOut.setTypeface(null, Typeface.NORMAL);

    textOut.setTypeface(null, Typeface.BOLD);

  • @himura128

    I'm not sure if this is correct, but I think it means that since OnCheckedChange is in a dif. class, we can't "see" it in our Tutorial1 class (probably bc this event handler is either not public or in a class thats not public...idk) but anyway. I think it just sets up the event handler for u...Remember in the button examples, Eclipse created a new OnClicked function for us? Well this is kinda the same thing...I think. lol.

  • @himura128

    I'm not sure if this is correct, but I think it means that since OnCheckedChange is in a dif. class, we can't "see" it in our Tutorial1 class (probably bc this event handler is either not public or in a class thats not public...idk) but anyway. I think it just sets up the event handler for u...Remember in the button eclipse created a new OnClicked function for us? Well this is kinda the same thing...I think. lol.

  • @CornboyzAndroid i suggest you'll create a new method that returns that listener, it's much more clean that way.

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more