我可以ListView从我的SQLiteDatabasein 填充我的项目lunch.java.现在我想点击一个项目(共8个项目ListView)并转到一个新的活动,Display.java并显示它的所有营养成分.
编辑后
lunch.java:
public void onItemClick(AdapterView<?> parent, View v, int pos, long id) {
switch(pos)
{
case 0 :
String mealName = (String) parent.getItemAtPosition(pos);
Cursor cursor = dbopener.getBreakfastDetails(mealName);
cursor.moveToNext();
id = cursor.getLong(cursor.getColumnIndex(mealName));
String message = cursor.getString(1) + "\n" + cursor.getInt(2);
Intent event1 = new Intent("com.edu.tp.iit.mns.Display");
event1.putExtra("name", id);
startActivity(event1);
break;
Run Code Online (Sandbox Code Playgroud)
Display.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.display);
TextView tv = (TextView) findViewById(R.id.tvfoodName);
Intent intent = getIntent();
long id …Run Code Online (Sandbox Code Playgroud)