Course Content

If you are facing any issue in playing video please use Firefox browser.

Course Content

Description

Listview with example in Android

Now we will see how we can design a practical list view stepwise.

  1. So for this we have created a new project by giving it's name as 'list' , and now we will see how to design its content.
  2. So it has xml file inside the ‘src’ folder which is inside the ‘app’ folder which is default generated.
  3. After that we will design its layout, for this we will open our 'res' folder.
  4. And after that we will see xml file, in which the linear layout is the default, so inside it we will now design a list view tag, and we will set the properties like its width and height.
  5. Now we have to design a second layout file which we will give the name xml. Now inside this we have to design a text view, in which we will set basic properties, such as width, height, padding, textStyle, textSize.
  6. Now we will see our main activity, for that we will now open java in the folder of 'java' which is inside our 'main' folder. We can see a default code there.
  7. First we will create an array of strings. We will specify the name of array as 'mobilearray', and then we will specify whatever content we need inside that array. All these contents will be displayed in our list.
  8. After this we have to create an ArrayAdapter. So after creating it, we'll keep its instance as 'adapter'. And after that its content work will be specified.
  9. After that we have to pass the arguments in which we will first pass 'localinstance', and then we have to set its layout, then we will use our 'res' folder to set the layout.
  10. Now we have to identify our list view here with the help of given Id.
  11. After that we have to set the adapter of List view, then we can use its instance here.
  12. Now we will see it by executing, going to the option of run in the menu, as soon as we click on the run app, our code will be displayed, we will be able to see the list that we had designed, and we will see all the contents that we had given inside the array.

FAQs

Recommended Courses

Share With Friend

Have a friend to whom you would want to share this course?

Download The Apps

App Preview Image
App QR Code Image
Code Scan or Download the app
Google Play Store
297K+ Downloads
App Download Section Circle 1
4.5 Rating
App Download Section Circle 2
10K+ Reviews
App Download Section Circle 3
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere