title: Dynamic ListView in Android Studio: Selecting random element and update list view
body: <pre><code>public class MyWorkout extends AppCompatActivity {
      Button addExercise
      // Record how many clicks
      int clickCounter=0;
      private ListView mListView;
      ArrayList&lt;String&gt; listItems = new ArrayList&lt;String&gt;()
      ArrayAdapter&lt;String&gt; adapter;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          SetContentView(R.layout.activity_my_workout);
          Toolbar MyWorkouttoolbar = (Toolbar) findViewById(R.id.MyWorkouttoolbar);
          setSupportActionBar(MyWorkouttoolbar);
          listItems.add("Power Clean");
          listItems.add("Dead Lift");
          listItems.add("Hang Clean");
          listItems.add("Military Press");
          listItems.add("Leg Press");
          listItems.add("Squat");
          listItems.add("Bench MAX");
          listItems.add("Squat MAX");
          listItems.add("Stair Stepper");
          listItems.add("Treadmill");
          listItems.add("Bike");
          listItems.add("Elliptical");
          listItems.add("Bicep Curls");
          listItems.add("Dumb Bell Squats");
          listItems.add("Goblet Squats");
          listItems.add("Bar Bell Curls");
          listItems.add("Bar Bell Bench Press");
          listItems.add("Dumb Bell Bench Press");
          listItems.add("Incline Bar Bell Bench Press");
          listItems.add("Incline Dumb Bell Bench Press");
          listItems.add("Decline Dumb Bell Bench Press");
          listItems.add("Decline Bar Bell Bench Press");
          listItems.add("Dumb Bell Lunges");
          listItems.add("Bar Bell Lunges");
          listItems.add("Dumb Bell Flys");
          listItems.add("Tricep Push Downs");
  
          if (mListView == null) {
              mListView = (ListView) findViewById(R.id.MyWorkoutlistView);
          }
          adapter = new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1,listItems);
          setListAdapter(adapter);
          addExercise = (Button) findViewById(R.id.addExercise);
          addExercise.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Collections.shuffle(listItems);
                  adapter.getItem(4);
                  adapter.notifyDataSetChanged();
              }
          });
       }
  
       private void updateListView(){
           ListView listView = (ListView)findViewById(R.id.MyWorkoutlistView);
       }
  
       // method which will handle dynamic insertion
       public void addItems(View v) {
          listItems.add("Clicked : "+clickCounter++);
          adapter.notifyDataSetChanged();
       }
  
       protected ListView getListView(){
           if (mListView==null){
               mListView = (ListView) findViewById(R.id.MyWorkoutlistView);
           }
           return mListView;
       }
  
       protected void setListAdapter(ListAdapter adapter){
           getListView().setAdapter(adapter);
       }
  
       protected ListAdapter getListAdapter(){
           ListAdapter adapter = getListView().getAdapter();
           if (adapter instanceof HeaderViewListAdapter){
              return ((HeaderViewListAdapter)adapter).getWrappedAdapter();
          } else {
              return adapter;
          }
      }
  </code></pre>
  
  <p>I have a list view populated with exercises. I would like to randomly select an element in an array and add that random element to another list view. </p>
  
  <p>Also is it possible to change the original exercise list view to display only the random element? </p>
  
  <p>I am new to android studio, so if I am unclear let me know and I will explain better. Thank you </p>