I have been looking all over the internet and i found some good guides for programing in android but i still dont fully understand what exactly is going on with this thing
i thought this would be like programing a java program but its very different.. there are lots of xml files and there is this thing called “activity” and an “intent” of which i dont understand how they work.. same with the way of displaying things..there is this xml file that designs the way the app looks but when you i used this code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the message from the intent
Intent intent = getIntent();
String message = intent.getStringExtra(FirsttimeActivity.EXTRA_MESSAGE);
// Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
setContentView(textView);
}
the text box that was there before disappeared and a normal text appeared instead.. what just happand here? how do i replace the text with something else after that? how do i go back to the normal view?
so my qoustions are as follows:
what does an “activity” mean? whats the parallel in a normal java project?
whats an intent and how does it work?
how do i control the display? how come it changed when i entered that code?
thanx
An Activity is an essential part of Android development. Its basically a class which you can use to represent any number of UIs. The onCreate method is not a constructor, but is called as soon as the Activity is started, so initializing your information in there is a good idea. The program knows which Activity it is starting with within your android manifest file with the line of code
There is no real parallel to a ‘normal’ java project. An intent is used to pass information from Activity to Activity. The best way to learn about Intents is to read about them here :
http://developer.android.com/reference/android/content/Intent.html
The actual visual part of what you see, is controlled in the XML files which are located in the /res/layout/ folder within your project.