
protected void onCreate(Bundle savedInstanceState) // Recreate the activity for the theme change to take effect. In the onCreate() method of MainActivity, find your score TextView elements by id and assign them to the member variables. Member variables for holding the score private int mScore1 private int mScore2 Member variables for holding the score private int mScore1 private int mScore2 Ĭreate two TextView member variables to hold references to the TextView elements. 1.5 Initialize the TextView elements and score count variablesĬreate two integer member variables representing the score of each team. This allows for your app to be easily localized into different languages. This process removes all of your strings from the Java code and puts them in the strings.xml file. Create Drawable resources in XML and use them as backgrounds for your Button elements. The second line of code now looks something like this: Īdd the following attributes (without removing the existing attributes)Īdd the following attributes to the ImageButton elements on the left side of the layout: android:contentDescription="Minus Button"Īdd the following attributes to the ImageButton elements on the right side of the layout: android:contentDescription="Plus Button"Įxtract all of your string resources. The project shows an activity which uses a theme colour attribute to set the text colour of a TextView widget, and a simple shape drawable as a background for a. Create a new app and add Button and TextView elements to the layout. At the top, or root, of the View hierarchy is the ConstraintLayout ViewGroup: Ĭhange this ViewGroup to LinearLayout. Open activity_main.xml and click the Text tab to see the XML code.

The first step is to change the layout from ConstraintLayout to LinearLayout: Accept the default Activity name ( MainActivity), and make sure the Generate Layout file and Backwards Compatibility (AppCompat) options are checked.Accept the default minimum SDK and choose the Empty Activity template.

Start Android Studio and create a new Android Studio project with the name Scorekeeper.custom import import import import import import import import import .5.1: Drawables, styles, and themes Task 1: Create the Scorekeeper app 1.1 Create the project To create a new style or theme, open your projects res/values/styles.xml file.
