Show scrollbar ListView android

ListView is like a tableView in iPhone or iOS . In this example i will show you how to add a String Array in to the ListView and also make the listView Scrollable.

First the xml file . Here the line

android:scrollbars=vertical

will make the scrolling vertically

Now the java file

package com.Ch.Example.pack; import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.AdapterView.OnItemClickListener; public class Example extends Activity { /** Called when the activity is first created. */ ListView list; private List List_file; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); List_file =new ArrayList(); list = (ListView)findViewById(R.id.listview); CreateListView(); } private void CreateListView() { List_file.add("Coderzheaven"); List_file.add("Google"); List_file.add("Android"); List_file.add("iPhone"); List_file.add("Apple"); //Create an adapter for the listView and add the ArrayList to the adapter. list.setAdapter(new ArrayAdapter(Example.this, android.R.layout.simple_list_item_1,List_file)); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView arg0, View arg1, int arg2,long arg3) { //args2 is the listViews Selected index } }); } }

The screen will be like this

Show scrollbar ListView android

Here is a other useful posts related to listviews.

1. ListView with Sections in android.
2. A Simple Layout with two listViews.

More Similar Posts

  • Filtering in ListView Flutter
  • Creating Dynamic Forms & Get Data from Dynamic Forms
  • Google's Flutter Quick Tips
  • Easily Parse JSON, Create JSON Model Classes, Show
  • Download ZIP, Extract it and Show the images file in
  • Filtering a ListView in Flutter using a onChange on
  • Expanded/ Multi-Level List in Flutter for Android and iOS
  • App Theming in Flutter - Dark Mode/ Light Mode
  • Flutter - Tips & Tricks
  • Flutter Tutorial - List Pull to Refresh and Swipe to
  • Flutter Tutorials - CloudFireStore CRUD Operations
  • Parsing RSS Feeds in Flutter
  • How to use YouTube APIs and Play YouTube videos inFlutter.
  • Flutter Tutorials - Navigation Drawer in Flutter -
  • Easy StateManagement in Flutter using Providers,
  • Custom Splash Screen in Flutter for Android and iOS.
  • Screen Shot 2019-07-12 at 9.08.08 PM
  • Minimum Distances between Similar numbers in an array
  • Collapsing AppBar in Flutter - Android and iOS
  • Firebase Push Notifications in Flutter
  • Wrap Widget & Chip Widgets in Flutter
  • Firebase Storage - Uploading and Downloading files &
  • Flutter Tutorial - Navigation and Passing params
  • BLOC Pattern in Flutter explained with Real Example
  • Auto Generate JSON Models in Flutter, Filtering a