我在 ListView 中显示数据库中的名称;这工作正常。我想实现一个 onclicklistener 的函数,将该字符串传递给另一个活动。我可以让它有点工作,但它只通过 andoid.database.sqlite... 下面是我尝试 OnItemClickLIsener 无济于事的代码。任何帮助将不胜感激。
private MyExercisesDB myExerciseDB;
private ListView myExerciseList;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.custom_exe);
myExerciseList = (ListView)this.findViewById(R.id.custExerLV);
openDB();
populateLVFromDB();
myExerciseList.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent, View v, int position,long id)
{
String selectedFromList = myExerciseList.getItemAtPosition(position).toString();
GlobalVars.setVar(selectedFromList);
startActivity(new Intent(CustomExeActivity.this, AddToCalendar.class));
}
});