Android App Development for Beginners – 15 – Adding More Widgets

Share it with your friends Like

Thanks! Share it with your friends!


Visit my website at for all of my videos and tutorials!
Have questions or looking for source code? Check out the forum at

My Profile –
Facebook –
Google+ –
Twitter –!/bucky_roberts
Donate –


tasfox tasfox says:

I don't get it what does this do :

RelativeLayout.LayoutParams usernameDetails = new RelativeLayout.LayoutParams(

why do wee have two wrap_content ? why two of them and what does each one do ?

this is my skype for anyone who is also following the cource we could discuss and ask questions : fairdair

xodemifan1xo says:

hey the setId(1); doesnt work it gives an error it wont work in an emulator please respond quick

tahto tae says:

its really hard to find the source code in your website. your search bar doesnt work.

James Pope says:

For the object ID's, e.g. redButton.setId(2);, are those Id's public? Can I call and use them as parameters in other classes/methods?

Akhil Maripally says:

Why do we have to learn about setting buttons,layouts,etc when have android studio providing us so many tools??is it important to learn for interviews or something?

Cyber Allien says:

Why you don't just use XML ???

Epicnerd73 says:

Why is there a red line under the setId() method calls? It still works though, but the error is really annoying me.. It says "Expected resource of type id"

Danish Shah (Ddev) says:

Hey Bucky, just got a question.
What if I need to set the width or height in terms of "dp" of "pixels" using LayoutParams??

TexasBassFishing says:

how does the usernameDetails container know to wrap the contents of the EditText widget and not the redButton? same thing goes for the buttonDetails. how did it know to wrap the button- because it was the only thing in the relativeLayout? but then when u have multiple widgets shouldn't u be specifying something like: RelativeLayout.LayoutParams usernameDetails.username = new…. because without the .username then how does it know usernameDetails is for the username widget
edit: so i guess it works because when you add the final 2 statements to add the button and text field to the view, you add the button along with the buttonDetails and the edittext with the usernameDetails. that makes more sense now. It's not necessarily that it knows usernameDetails is for the username text field, it's more ur adding username with some rules u named (for convenience) usernameDetails.

Mikhail Kashtaev says:

I dont get why we have to put the usernameDetails above the redButton and not the redButtonDetails.

Dreamsheker says:

I dont know anything about java.
I have knowledge of basic concept of c++ and c.
should I continue with this tutorials or just come back after learning Java

Rian ady raihandiwan says:

someone please explain too me what the diference & benefit between create the GUI manually and create it by drag & drop.. i did create java app with gui, all i do just drag & drop the components… im litte bit confuse

Yes dickhead, my avatar is a pony says:

Typos: Gotta Catch 'em All.

Sachi Singla says:

Can anybody plz clear to me that where exactly are we coding the app ?? 
In or activity_main.xml…
when me make changes to any one of them,the corresponsing change doesn't occur in the other file but when we run the emulator,changes from both of them are shown !!
I'm really confused about which file exactly  to use to code !!

genial Chakma says:

thanks for this tutorial,,,,,,,,,,,,,,

roi shaul says:

Thank you man!!!

‫قناة الوثائقية الاسلامية‬‎ says:

why when i try to set ID  show me  erro !!

RivalezOwns says:

How Can i get rid of underscore on my EditText object?

John O'Brien says:

how to i label section on line, such as when you labled username imput//

guy hezi says:

omg dude's and and lads

i looked at the comment to see why my input is so high above and i cant figure it out

 //user input
        EditText userName = new EditText(this);
        RelativeLayout.LayoutParams userNameDetails = new RelativeLayout.LayoutParams(

        userNameDetails.addRule(RelativeLayout.ABOVE, redButton.getId());

        //add widget to layout(button is now child of layout)


Abhishek Gupta says:

Why we have asign ID to button. Why can't use its name instead? in this case 'redButton'

Samuel Hošovský says:

When setting margins, int values in this case refer to pixels? What is I would like to make it relative to user's device monitor configuration?

Write a comment