Translate this page to

Search Android

Search For Android Tutorials (NEW, Custom Search for Android Developers)
Loading

Wednesday, December 31, 2008

Code to show your XML Visual in Android

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

0 comments: