Custom Adapter in Listview, getting an objects variables
<p>I have a listview with a custom adapter, the adapter contains two <code>TextViews</code> and one <code>ImageButton</code>. The list contains objects of my class <code>Firm</code>. When a user presses the <code>ImageButton</code> I want to get some information from the <code>Firm</code> object, by using a <code>get()-method</code>. </p>

<p><strong>Some Codesnippets underneath</strong></p>

<p><strong>My CustomAdapter</strong></p>

<pre><code>import java.util.Vector;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class CustomAdapter extends ArrayAdapter&lt;Firm&gt;
{
 Context context;
 int layoutResourceId;   
 static String datesort; 
 ImageButton call;
 Firm mrb;

 Firm currentMRB;
 Vector&lt;Firm&gt; data;
/** Called when the activity is first created. */
// TODO Auto-generated constructor stub
public CustomAdapter(Context context, int layoutResourceId, Vector&lt;Firm&gt; data) 
{
    super(context,layoutResourceId,data);
    this.layoutResourceId = layoutResourceId;
    this.context=context;
    this.data = data;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
    View row = convertView;
    MyStringReaderHolder holder;

    if(row==null)
    {
        LayoutInflater inflater = ((Activity)context).getLayoutInflater();
        row = inflater.inflate(layoutResourceId, parent,false);

        holder= new MyStringReaderHolder();

        holder.gtumcaTvFirstName =(TextView)row.findViewById(R.id.gtumcaTvFirstName);
        holder.gtumcaTvLastName =(TextView)row.findViewById(R.id.gtumcaTvLastName);
        call = (ImageButton)row.findViewById(R.id.imageButton1);

        row.setTag(holder);
    }
    else
    {
        holder=(MyStringReaderHolder) row.getTag();
    }

    mrb =data.elementAt(position);
    System.out.println("Position="+position);

    holder.gtumcaTvFirstName.setText(mrb.getCompanyName());
    int price = (int)mrb.getPrice();
    String priceString = Integer.toString(price);
    holder.gtumcaTvLastName.setText(priceString);


    call.setOnClickListener(new OnClickListener() {

        public void onClick(View arg0) {


            Toast.makeText(context, mrb.getNumber(), Toast.LENGTH_LONG).show(); 

        }
    });

    return row;

}
</code></pre>

<p>Look at the <code>getView()</code> function, this contains a <code>OnClickListener()</code> method that I want to run when the user presses one of the items in the <code>ListView</code>, the function should raise a <code>Toast</code> with the object's <code>get()</code> method</p>

<p>But it doesn't work. Does anybody know how I can complete this task? Thanks in advance. </p>

<p><strong>UPDATE</strong></p>

<p>I've found whats wrong, I forgot that the Button was a <code>ImageButton</code> rather than a regular <code>Button</code>. But how can I get the objects number? My Toast just generates random numbers from the getNumber() method based on all the objects, more specified I want the number of the object in e.g position 3 in my list. </p>
