没有从Listview OnItemClickListener获取String

时间:2013-08-21 22:13:56

标签: android android-listview android-sqlite onitemclicklistener

我在ListView中显示数据库中的名称;这工作正常。我想实现一个onclicklistener函数,它将该字符串传递给另一个活动。我可以让它有点工作,但它只通过andoid.database.sqlite ... 下面是我的代码,我尝试OnItemClickLIstener无济于事。任何帮助将不胜感激。

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));
        }

    });

0 个答案:

没有答案