I am having a class that extends View. I have another class that extends activity and I want to add the first class to be loaded inside the activity class. I tried the follo
Suggestion: avoid naming your classes names very close to already existing classes (eg. View, Activity);
Since you are extending View (which by default does not draw anything specific) you aren't able to see anything in your activity.
Start by extending TextView object to get a feel.
public class MyTextView extends TextView {
public MyTextView(Context c){
super(c);
}
// ----
public class MyActivity extends Activity {
MyTextView myTextView;
@Override
protected void onCreate(Bundle savedInstance){
super.onCreate(savedInstance);
setContentView(myTextView = new MyTextView(this);
myTextView.setText("It works!");
}
Hope this helps!