ListView with Button, Using ViewHolder within OnClick
<p>I am attempting to create a list of buttons paired with text. Whenever a button in the list is clicked, I want to increment the integer value in the associated text view. My plan was to use the following code, but I'm having an error using <code>viewHolder</code> within the <code>OnClickListener</code> because <code>viewHolder</code> is not final, and it can't be in order to manipulate it within the <code>onClick</code>. How can I modify the associated text value?</p>

<pre><code>public View getView(final int position, View convertView, ViewGroup parent){
    ViewHolder viewHolder = null;
    if (convertView == null) {
        LayoutInflater inflater = ((Activity) context).getLayoutInflater();
        convertView = inflater.inflate(R.layout.row, null);
        viewHolder = new ViewHolder();
        viewHolder.text = (TextView) convertView.findViewById(R.id.playerScore);
        viewHolder.button = (Button) convertView.findViewById(R.id.playerButton);
        viewHolder.button.setOnClickListener(new View.OnClickListener() {
            protected String scoreToSet;
            @Override
            public void onClick(View v) {
                 viewHolder.text.setText(Integer.toString(modelList.get(position).getScore() + 1)); //Error is occurring here
            }
        });
        convertView.setTag(viewHolder);
    }
    else{
        viewHolder = (ViewHolder) convertView.getTag();
        viewHolder.button.setText(modelList.get(position).getPlayer());
    }
    return convertView;
}
</code></pre>

<p>Thanks for the help!</p>