package com.example.amanda.scorekeeperversion4;

import android.content.Intent;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ListView;

public class MainActivity extends AppCompatActivity {

    //The adapter that knows how to create list item views given a cursor
    PlayerCursorAdapter mCursorAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Setup FAB to open EditorActivity
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, EditorActivity.class);
                Log.e("Main Activity OnCreate", "intent created");
                startActivity(intent);
            }
        });

        //Find the ListView which will be populated with the player data
        ListView playerListView = (ListView) findViewById(R.id.list_view_player);

        //TODO set empty view
//        //Find and set empty view on the ListView so that it only shows when the list has 0 items.
//        View emptyView = findViewById(R.id.empty_view);
//        playerListView.setEmptyView(emptyView);

        //Set up an Adapter to create a list item for each row of pet data in the Cursor
        //There is no pet data yet (until the loader finishes) so pass in null for the Cursor
        mCursorAdapter = new PlayerCursorAdapter(this, null);
        playerListView.setAdapter(mCursorAdapter);
    }
}

@@ -65,22 +65,82 @@
 content.
-Intent
+ContentUris;%0Aimport android.content.Intent;%0Aimport android.net.Uri
 ;%0Aimport
@@ -340,24 +340,139 @@
 .widget.
-ListView
+AdapterView;%0Aimport android.widget.ListView;%0A%0Aimport com.example.amanda.scorekeeperversion4.data.PlayerContract.PlayerEntry
 ;%0A%0Apubli
@@ -1962,16 +1962,700 @@
 dapter);
+%0A%0A        //set click listeners on each list item%0A        playerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() %7B%0A            @Override%0A            public void onItemClick(AdapterView%3C?%3E parent, View view, int position, long id) %7B%0A%0A                Intent intent = new Intent(MainActivity.this, EditorActivity.class);%0A%0A                //Append the id of the current pet to the content URI%0A                Uri currentPlayerUri = ContentUris.withAppendedId(PlayerEntry.CONTENT_URI, id);%0A%0A                //Set the URI on the data field of the intent%0A                intent.setData(currentPlayerUri);%0A%0A                startActivity(intent);%0A            %7D%0A        %7D);
 %0A    %7D%0A%7D

Set currentPlayerUri as data for the intent opening EditorActivity when list item is clicked