Android 如何使用onListItemClick方法从扩展ListActivity的类中获取所选项?

Android 如何使用onListItemClick方法从扩展ListActivity的类中获取所选项?,android,listactivity,Android,Listactivity,这是我的班级代码: public class SimpleCursorAdapterConLogoActivity extends ListActivity { private DatabaseHelper databaseHelper; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

这是我的班级代码:

public class SimpleCursorAdapterConLogoActivity extends ListActivity
{

    private DatabaseHelper databaseHelper;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        databaseHelper = new DatabaseHelper(this);

        String categoria=getIntent().getExtras().getString("categoria");
        Cursor c = databaseHelper.getProdottiByCategoria(categoria);
        startManagingCursor(c);
        setListAdapter(new ProdottiSimpleCursorAdapter(this, c));

    }



    @Override
    protected void onListItemClick(ListView l, View v, int position, long id)
    {
        TextView prodotto= (TextView) findViewById(R.id.prodotto);
        Cursor cursor=databaseHelper.getInfoProdotto(prodotto.getText().toString());  

        startManagingCursor(cursor);

        Intent nextScreen= new Intent(this,SchedaProdotto.class);

        while(cursor.moveToNext())
        {
            String name= cursor.getString( cursor.getColumnIndex("Name") );
            String price= cursor.getString(cursor.getColumnIndex("Price"));
            String link_image=cursor.getString(cursor.getColumnIndex("Link_image"));
            String descrizione= cursor.getString( cursor.getColumnIndex("Description") );

            nextScreen.putExtra("name",name);
            nextScreen.putExtra("price", price);
            nextScreen.putExtra("link_image", link_image);
            nextScreen.putExtra("description",description);
        }


        startActivity(nextScreen);

    }


    @Override
    protected void onDestroy()
    {
        super.onDestroy();
        databaseHelper.close();
    }

}
我只得到第一个项目的TextView的名称。 这是因为我在onListItemClick方法中使用:

TextView prodotto= (TextView) findViewById(R.id.prodotto);

我不知道如何获取与列表中选定项相关的TextView的名称

如果要扩展一个
光标或适配器
l.getItemAtPosition(position)
,则返回表示所单击行的光标

@Override
protected void onListItemClick(ListView l, View v, int position, long id {
    Cursor cursor = (Cursor) l.getItemAtPosition(position)
    Intent nextScreen= new Intent(this,SchedaProdotto.class);
    String name= cursor.getString( cursor.getColumnIndex("Name") );
    String price= cursor.getString(cursor.getColumnIndex("Price"));
    String link_image=cursor.getString(cursor.getColumnIndex("Link_image"));
    String descrizione= cursor.getString( cursor.getColumnIndex("Description") );

    nextScreen.putExtra("name",name);
    nextScreen.putExtra("price", price);
    nextScreen.putExtra("link_image", link_image);
    nextScreen.putExtra("description",description);
    startActivity(nextScreen);
}
应该这样做

TextView电视=(TextView)v.findViewById(R.id.yourTextView);