Should my business logic be in the fragment or the activity above?
<p>I'm trying to use fragments and a list view with an array adapter, and having trouble calling my method from the onClickListener in the array adapter.</p>

<p>If I understand the pattern correctly, a fragment should be self-sufficient, so I want to put my business logic in there. But I can't manage to call it from the array adapter. I can call it if I put it in the main activity, but doesn't that preclude me from using the fragment in another activity and break the paradigm?</p>

<p>Is my business logic in the wrong place, or am I not calling it correctly?</p>

<p>Here is my ArrayAdapter;</p>

<pre><code>public class RecipientsListAdapter extends ArrayAdapter&lt;Recipient&gt;{

    Context context;
    int layoutResourceId;   
    Recipient data[] = null;

    public RecipientsListAdapter(Context context, int layoutResourceId, Recipient[] data) {
        super(context, layoutResourceId, data);
        this.layoutResourceId = layoutResourceId;
        this.context = context;
        this.data = data;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        View row = convertView;
        RecipientHolder holder = null;

        final boolean isLastRow = (position == data.length-1);

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

            holder = new RecipientHolder();
            holder.imgIcon = (ImageView)row.findViewById(R.id.imgIcon);
            holder.txtTitle = (TextView)row.findViewById(R.id.txtTitle);

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

        final Recipient recipient = data[position];
        holder.txtTitle.setText(recipient.displayName);
        holder.imgIcon.setImageResource(recipient.icon);

        row.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                ((MainActivity)context).onChildItemSelected(position);
                if(isLastRow){
                //((RecipientsFragment).getContext()).launchContactPicker();


                    ((MainActivity)context)).launchContactPicker();


                }
                else{
                    Toast.makeText(getContext(), recipient.displayName, Toast.LENGTH_SHORT).show();
                }
            }
        });

        return row;
    }
</code></pre>
