GUI Objects
Here you can see we’ve added two starting objects. An arraylist of “ImageView” objects called “img_d_cards” and a “TextView” object called “txt_instruct“. These are simply Java member variables that are going to link to their respective items in our XML file. You can see inside the onCreate method we are instantiating those objects so that they “point to” the correct items on our UI.

findViewById
The method “findViewById” is fairly self-explanatory, it simply allows you to refer to any element you’ve named in your XML. Notice that the name we used in our XML file has the type of object as a suffix and the object reference here in the Java class has it as a prefix? This makes the reference procedure a bit easier to remember. I suggest you stick with this naming scheme in future projects, it’ll make your life much easier!

Casting
When you see an object type inside brackets like in this line:

txt_instruct = (TextView) findViewById(R.id.instruct_txt);

What’s happening is we’re telling the code on the right-hand side of the bolded phrase to become (in this particular instance) a “TextView” object. This is what’s known as casting which basically converts one object type into another. So in our case, the output from “findViewById” is being converted into a “TextView” object before it goes into the “txt_instruct” object.

Okay! Now it’s time to see if you can create the other required objects and instantiate them. It’s really no different to what we’ve already done here, the only unknown element is how you create buttons, they will simply be “Button” objects. If you get stuck, as usual, ask below.