Code to show your XML Visual in Android

Public on December 31, 2008
After posting some layout related xml examples in Android, i realized that there is no example on how to set your xml as your view/presentation layer. Here is the code:
package <yourPackage, example: com.almondmendoza.firstDemo>
import android.app.Activity;
import android.os.Bundle;

public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.main);
}
}


Quick Explanation
If you had developed in Rails/CakePHP like framework, this code, this.setContentView(R.layout.main); is like setting which layout (R.layout.main) to use to your controller (Activity).

I'll update the previous post to point to this. Hope it helps

Update History
   Jan 17, 2012 - Visual Update




[Advertising]Faster Thinking - Speed up your brain


Faster Thinking Game



sentiment_satisfied Emoticon