// SquareBallRectangleActivity.kt Copyright (c) Kari Laitinen // http://www.naturalprogramming.com/ // 2013-02-13 File created. // 2017-12-27 Kotlin version created. /* This application displays a square, ball, or rectangle, depending on which radio button is pressed. The application consists of the following files: main/java/square/ball/rectangle/SquareBallRectangleActivity.kt main/java/square/ball/rectangle/SquareBallRectangleView.kt main/res/layout/activity_square_ball_rectangle.xml To run this program in Android Studio, create a project with SquareBallRectangleActivity as its main class, and use the package name below. Then you have to copy the above-mentioned files to your project. */ package square.ball.rectangle import android.app.Activity import android.os.Bundle import android.view.View class SquareBallRectangleActivity : Activity() { public override fun onCreate( savedInstanceState: Bundle? ) { super.onCreate( savedInstanceState ) setContentView( R.layout.activity_square_ball_rectangle ) } fun square_shape_selected(view: View) { val square_ball_rectangle_view = findViewById(R.id.square_ball_rectangle_view) as SquareBallRectangleView square_ball_rectangle_view.set_shape_to_draw( "Square" ) } fun ball_shape_selected(view: View) { val square_ball_rectangle_view = findViewById(R.id.square_ball_rectangle_view) as SquareBallRectangleView square_ball_rectangle_view.set_shape_to_draw( "Ball" ) } fun rectangle_shape_selected(view: View) { val square_ball_rectangle_view = findViewById(R.id.square_ball_rectangle_view) as SquareBallRectangleView square_ball_rectangle_view.set_shape_to_draw( "Rectangle" ) } }