Screen is white & the System.out.println() within onDraw in never called.
This is my activity_main.xml
<foo.packagename.MyView
android:id="@+id/myView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
The custom view class:
public class MyView extends View {
public MyView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
System.out.println("This line is called");
while (true) {
invalidate();
}
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.GREEN);
System.out.println("This line is never printed");
}
The main activity:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
System.out.println("This line is called");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
View myView = findViewById(R.id.myView);
}
}