我有一个显示对象列表的列表视图,我希望列表中每个项目的单击项目侦听器都可以启动一个新活动并将该对象的属性传递给它,但是我不确定如何去做这个。到目前为止,我的代码在下面,并且我包括了创建对象所属类的位置。感谢您的帮助。
public class Recipe {
private String Id;
private String Name;
private String Calories;
private String Carbs;
private String Fats;
private String Protein;
private String Link;
private boolean Featured;
private String Keywords;
public Recipe(){
}
final recipeList adapter = new recipeList(this, listOfRecipes);
final ListView listView = (ListView) findViewById(R.id.listViewRecipes);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
@Override
public void onItemClick(AdapterView parent, View view, int position, long id) {
Intent intent = new Intent(featuredRecipesActivity.this, webViewActivity.class);
//intent.putExtra("url", Item.);
startActivity(intent);
}
});