Multiplication Tables Android App
In this post, we will be demonstrating how to create a simple multiplication tables app using Android Studio in Java.
We will be using a ListView to display the multiplication table of a number entered by the user.
ListView - ListView in Android is a view which contains the group of items and display them in a scrollable list. ListView is a default scrollable which does not user other scroll view.
Now that we know what a ListView is, lets begin making the app.
For this, we will require an EditText where in the user can input a number, a Button and a ListView which will display the multiplication table of the number entered by the user.
In the activity_main.xml file , write the code as follows:
Now in the MainActivity,java file , when the user clicks the button, we will call the fillList() methodt that will populate our ListView with the multiplication table. Write the code as follows:
We will need to create an an xml file that will define the structure of how the elements in the ListView will appear. So create a new layout resource file (in our case it is row.xml). Now add the following code to this file.
And that's it .Now run and test your app.
Output:
<activity
android:name=".activities.MainActivity"
android:windowSoftInputMode="adjustPan">
</activity> in the activity tag in AndroidManifest file. )
Comments
Post a Comment