setOnItemClickListener

setOnItemClickListenerでタップした時の処理

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

        ListView myListView = (ListView) findViewById(R.id.myListView);

        ArrayList<User> users = new ArrayList<>();
        int[] icons = {
                R.mipmap.ic_launcher,
                R.mipmap.ic_launcher,
                R.mipmap.ic_launcher,
        };
        String[] names = {
                "yoshida",
                "kobayashi",
                "igawa"
        };

        String[] locs = {
                "Hamamatsucho",
                "Marunouchi",
                "Ebisu"
        };

        for(int i = 0; i < icons.length; i++){
            User user = new User();
            user.setIcon(BitmapFactory.decodeResource(
                    getResources(),
                    icons&#91;i&#93;
            ));
            user.setName(names&#91;i&#93;);
            user.setLoc(locs&#91;i&#93;);
            users.add(user);
        }
        UserAdapter adapter = new UserAdapter(this, 0, users);
        myListView.setAdapter(adapter);
        myListView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
           @Override
           public void onItemClick(
                   AdapterView<?> adapterView,
                   View view,
                   int i,
                   long l
           ) {
                TextView name = (TextView) view.findViewById(R.id.name);
                Toast.makeText(
                        MainActivity.this,
                        Integer.toString(i) + ":" + name.getText().toString(),
                        Toast.LENGTH_SHORT
                ).show();
                name.setText("Tapped");
           }
        });

    }

こりゃ覚えること多すぎて、思ってたより時間かかりそーだ