title: getView() parameter passing in android adapter
body: <pre><code>@Override
  public View getView(int position, View convertView, ViewGroup parent) {
  
      View vi=convertView;
       viewholder holder;
       if(vi==null){
          LayoutInflater inflater = (LayoutInflater) context.getSystemService (Context.LAYOUT_INFLATER_SERVICE);
              vi = inflater.inflate(R.layout.row, null);
           holder=new viewholder();
  
              holder.tview1=(TextView)vi.findViewById(R.id.MXname);
           holder.tview1.setOnClickListener(new OnClickListener(){
                  public void onClick(View v){
  
                      Log.d("Name view Click","in the list");
                      }
                  }
           );
  
              holder.tview2=(TextView)vi.findViewById(R.id.MXtnumber);
              holder.tview2.setOnClickListener(new OnClickListener(){
                  public void onClick(View v){
                      Log.d("Number view Click","in the list"+position);
                  }
                  }
            );
  
             holder.imageview=(ImageView)vi.findViewById(R.id.MXdialer);
             holder.imageview.setTag(position);
           holder.imageview.setOnClickListener(new OnClickListener(){
                  public void onClick(View v){
              //Integer no = new Integer(0);
                          // get the number to dial and pass to DialNo
                  //madapter.this.DialNo();
                      Log.d("Dialer view Click","in the list");
                      }
                  }
           );
           vi.setTag(holder);
          }
          else
              holder=(viewholder)vi.getTag();
  
  
        return vi;
  
  
      }
  }
  }
  </code></pre>
  
  <p>PLease see a draft of getview() adapter code above related to listview/android, When i try using "position" parameter in any of the onclick methods above I get error "<strong>Cannot refer to a non-final variable position inside an inner class defined in a different method"</strong>
  The only work around I can do is make it a final variable and then access that final variable in onclick() method. Please suggest if there is any other way of doing this without using final variable. thanks in advance</p>