Am I creating a java object with both?
Technically, yes. Almost everything you see on the screen is represented by an object. The XML file itself does not really "create" objects directly though. When your activity starts, another piece of Java code will read the XML file and create objects according to that. You usually have a call to setContentView
in onCreate
, right?
setContentView(R.layout.blah_blah_blah);
This is where you tell the Android SDK to read your XML file and create all the views.
Also is the java textview for easier change in text and functionality while xml does the main layout/view of an application?
Usually, yes, this is the case. When you want to dynamically add views depending on user interaction (e.g. pressing a button), you add the views in Java. If you have some views that never change, do it in XML.
However, this does not mean that you can't create static views in Java. You can. It's just that it's too much code to write so few people do it.
You can also create an XML file, and inflate the view inside it using Java code.