title: Creating a class instance and naming it using a local variable (android)
body: <p>I'm working on a small/basic android application that allows users to create items in a ListView and keep some statistics on these items (such as click frequency, etc.). Right now I have it so users can enter the name of their new item and once they click the create button it adds the element to the ListView. If the user selects one of the items in the list it opens a second activity where they will be able to analyze statistics, reset the click counter, etc. </p>
  
  <p><img src="https://i.stack.imgur.com/LMzB4.png" alt="This is what the application looks like"></p>
  
  <p>(* Side info *: 
  MainActivity.java is the main activity as shown above. ClickerActivity.java is the second activity that is used to display the statistics for each clicker. Clicker.java is a class that holds name/click count/statistics for each clicker.
  )</p>
  
  <p>My approach has been that when the 'New Clicker' button is pressed I should take the name they've given and add it to the ListView and create a Clicker class object (which is used to track statistics). These Clicker objects would be stored locally in an ArrayList, so that I can grow and shrink the list with ease. Then start the clickerActivity - passing the Clicker class object as a parameter.</p>
  
  <p>This leaves me with a few questions, <strong>first:</strong> how can I create an instance of this class dynamically and give the variable representation a meaningful name (on the go). I was thinking of using the string variable the user enters to name the clicker but I am not sure if this is allowed.</p>
  
  <p>ex. </p>
  
  <pre><code>// This is the string name the user chooses for the new clicker
  String newClickerName = clickerName.getText().toString();
  Clicker newClickerName = new Clicker();
  // Start the activity and pass the clicker object.
  </code></pre>
  
  <p>I realize that the above code wouldn't work but it is my best way of showing what I am trying to do. I've seen some posts where people are suggesting using </p>
  
  <pre><code>Class var = Class.forName(classname);
  </code></pre>
  
  <p>But I am not sure that is what I am looking for. </p>
  
  <p><strong>Secondly</strong> If you find that this is not a good design choice (I don't mean graphical) then please voice your opinion on how it could be improved. I am new to this and appreciate the feedback. </p>
  
  <p>Lastly, thank you for taking the time to read my question. If there is any confusion please voice it and I will do my best to clarify.</p>