Q:

list.add is crashing when I try to add user defined object

I'm trying to create Android app that takes user input to create a player list and keep     the order but I've been trying to do this with an ArrayList that takes int position and String name but when I try to playList.add(player) my app crashes.
I have been trying to add to an ArrayList playerList = new ArrayList<Player>(); I have tried List<Player> = new ArrayList<Player> as with no luck.
 The data is being passed back and shows up in Toast but now ListView item.  What am I missing?
This is my MainActivity:
    import java.util.ArrayList;
    import java.util.List;
    import android.app.Activity;
    import android.content.Intent;
    import android.content.SharedPreferences;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MotionEvent;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.view.View.OnTouchListener;
    import android.widget.Button;
    import android.widget.ListView;
    import android.widget.TableRow;
    import android.widget.TextView;
    import android.widget.Toast;

    public class MainActivity extends Activity implements OnTouchListener {
        private static final int REQUEST_CODE = 10;
        private SharedPreferences savedPlayerPositions;
        private PlayerActivity playerActivity;
        public List<Player> playerList = new ArrayList<Player>();
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            // set up preferences
            savedPlayerPositions = getSharedPreferences("playerPositions",
                    MODE_PRIVATE);

            ListView lv = (ListView) findViewById(R.id.list);
            List<Player> playerList = new ArrayList<Player>();

            CustomListViewAdapter adapter = new CustomListViewAdapter(this,
                    playerList);
            lv.setAdapter(adapter);

            Button addPlayerButton = (Button) findViewById(R.id.button1);
            addPlayerButton.setOnClickListener(addPlayerButtonListener);

            playerActivity = new PlayerActivity();
        }

        @Override
        public boolean onCreateOptionsMenu(Menu menu) {

            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }

        public OnClickListener addPlayerButtonListener = new OnClickListener() {

            @Override
            public void onClick(View v) {
                // onClick go to player input screen and PlayerActivity
                Intent intent = new Intent();
                intent.setClass(MainActivity.this, PlayerActivity.class);
                startActivityForResult(intent, REQUEST_CODE);
            }
        };
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == 10) {

        String position = data.getStringExtra("battingPosition");
        String name = data.getStringExtra("playerName");
        int positionInt = Integer.valueOf(position);
        Player player = new Player(positionInt, name);
        **playerList.add(player);**
        Toast.makeText(getApplicationContext(), position + " " + name,
                Toast.LENGTH_LONG).show();
    }

Here is my customListViewAdapter:
    import android.app.Activity;
    import android.content.Context;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.BaseAdapter;
    import android.widget.Button;
    import android.widget.TextView;

    public class CustomListViewAdapter extends BaseAdapter
    {  
        LayoutInflater inflater;
        List<Player> playerList;

        public CustomListViewAdapter(Activity context, List<Player> playerList) {  
            super();

            this.playerList = playerList;
            this.inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);}

        @Override  
        public int getCount() {  
            // TODO Auto-generated method stub  
            return playerList.size();  }  

        @Override  
        public Object getItem(int position) {  
            // TODO Auto-generated method stub  
            return null;  }  

        @Override  
        public long getItemId(int position) {  
            // TODO Auto-generated method stub  
            return 0;  }

        @Override  
        public View getView(final int position, View convertView, ViewGroup parent) {  
            // TODO Auto-generated method stub  

            Player player = playerList.get(position);
            View vi=convertView;

            if(convertView==null)
                vi = inflater.inflate(R.layout.new_player_view, null);

            //assign components from new_player_view
            TextView playerInfo = (TextView)vi.findViewById(R.id.txtV_player_input_name_title);
            Button editButton = (Button) vi.findViewById(R.id.btn_Edit_Title);
            editButton.setOnClickListener(MainActivity.editPlayerButtonListener);

            playerInfo.setText(player.batPosition + " " + player.name);

            return vi;  
        }
    }

xml mainActivity:
   <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/txtV_battingOrder_Title"
            android:textSize="20sp" />

        <Button
            android:id="@+id/button1"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/btn_AddButton_title" />

        <ListView
            android:id="@+id/list"
            android:layout_width="fill_parent"
            android:layout_height="442dp"
            android:layout_weight="0.89" >
        </ListView>

    </LinearLayout>

Row that is added to listView:
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@android:color/transparent"
        android:padding="5dp" >

        <TextView
            android:id="@+id/txtV_player_input_name_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="25dp"
            android:layout_marginTop="21dp"
            android:maxLength="2"
            android:maxLines="1"
            android:width="180dp" />

        <Button
            android:id="@+id/btn_Edit_Title"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="@dimen/btn_edit_player_width"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/txtV_player_input_position_title"
            android:layout_alignBottom="@+id/txtV_player_input_position_title"
            android:layout_alignParentRight="true"
            android:layout_marginRight="14dp"
            android:padding="3dp"
            android:text="@string/bnt_Edit_title" />

    </RelativeLayout>

A:

Change:
public List<Player> playerList = new ArrayList<Player>();

to 
public ArrayList<Player> playerList = new ArrayList<Player>();

And also change inside your onCreate:
List<Player> playerList = new ArrayList<Player>();

to
playerList = new ArrayList<Player>();

but you don't have to redeclare twice since onCreate is only ever called once in an Activity's lifetime.
You will also have to call:
adapter.notifyDataSetChanged(); 

each time the playlist array is changed.

