2011-11-27 61 views
0

我是android开发新手。我只想知道如何在我们正在导航的类中访问变量(例如textview变量),以便我可以根据点击的listview更改它的值。android listview and intent

这里是一些代码

protected void onListItemClick(ListView l, View v, int position, long id) { 
    // TODO Auto-generated method stub 
    super.onListItemClick(l, v, position, id); 



     Intent openStartingPoint = new Intent("com.name.MainClass"); 

     startActivity(openStartingPoint);} 

感谢

回答

2

最强大的这样做的方法是把信息的意图。

更改为

Intent openStartingPoint = new Intent(this, com.name.MainClass.class); 
    openStartingPoint.putExtra("position", position); 
    startActivity(openStartingPoint);} 

,并在recieving活动的onCreate你写:

Intent openStartingPoint = getIntent(); 
    int position = openStartingPoint.getIntExtra("position");