listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Bundle bundle = new Bundle(); bundle.putInt("xu", teachers.get(position).getId()); bundle.putString("name", teachers.get(position).getName()); bundle.putString("xi", teachers.get(position).getXibie()); Intent intent = new Intent(MainActivity.this, Main2Activity.class); intent.putExtras(bundle); startActivity(intent); } }); public class Main2Activity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); Bundle bundle=getIntent().getExtras(); int id=bundle.getInt("xu"); String name=bundle.getString("name"); String xi=bundle.getString("xi"); Toast.makeText(this, ""+id+name+xi, Toast.LENGTH_SHORT).show(); } }
自己看的,不必写的太详细。这个够了。