This is a very basic question, I know, but I cannot seem to figure it out on my own. While the Android tutorial will help you make a practice app, it does not really tell you what you are doing. (I have already successfully completed their tutorial.) All of my searches have come up with less newbish questions without answering my question. So here is my beginner’s question:
I want to display the text “Sup World.” What am I doing wrong? I am sure the null is wrong, but I cannot figure out what should actually be there. “this” does not work. And with null in there, setContextView does not exist.
package com.evorlor.testcode;
import android.widget.TextView;
public class SupWorld {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String message = "Sup world.";
TextView textView = new TextView(null);
textView.setTextSize(40);
textView.setText(message);
setContentView(textView);
}
}
My issue is not in getting to my SupWorld class, is it?:
package com.evorlor.testcode;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(this, SupWorld.class);
startActivity(intent);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Change your Code as:
Declares above activity class in
AndroidManifest.xml:apart this you will to look some good tutorials for Creating your first application in android see these
http://www.mkyong.com/android/android-activity-from-one-screen-to-another-screen/
http://developer.android.com/training/basics/firstapp/index.html