title: create a global OnClickListener Android
body: <p>Hi im wanting to create an onClickListener() in a Global.java class and then pass it variables this is so i can reuse the on click listener for different lists within fragments. heres what i have tried so far but I'm getting a few errors.</p>
  
  <pre><code>public static OnClickListener onClickListener(Context activityContext, View myView, ArrayAdapter&lt;?&gt; myadapter, int position ){
  
               OnClickListener onClickListener = new OnClickListener();
  
               @Override
               public static void onClick(AdapterView&lt;?&gt; adapter, View v, int pos, long arg3) 
               {
                     String value = (String)adapter.getItemAtPosition(pos); 
                     // assuming string and if you want to get the value on click of list item
                     // do what you intend to do on click of listview row
               }
  
               return onClickListener;
  
           }
  </code></pre>
  
  <p>then in my activity i do this</p>
  
  <pre><code>listView.setOnClickListener(Global.onClickListener(this, v, myAdapter, position));
  </code></pre>
  
  <p>These are the errors i'm getting in the Global.java</p>
  
  <pre><code>Syntax error on token ",", ; expected   
  Syntax error on token ",", ; expected   
  Syntax error on token ",", ; expected   
  Syntax error on token "(", ; expected   
  Syntax error on token ")", ; expected   
  void is an invalid type for the variable onClick
  Cannot instantiate the type DialogInterface.OnClickListener
  </code></pre>