Android ListView.onItemLongClick-获取项目';s元素

Android ListView.onItemLongClick-获取项目';s元素,android,get,row,Android,Get,Row,我使用TextView创建了linearlayout,这是ListView的行(因为我需要一个表:)。它是listview行的布局示例: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:paddingTop="4dip" android:paddingB

我使用TextView创建了linearlayout,这是ListView的行(因为我需要一个表:)。它是listview行的布局示例:

   <?xml version="1.0" encoding="utf-8"?>
<LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:paddingTop="4dip"
     android:paddingBottom="6dip"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal">

     <TextView android:id="@+id/first_name"
         android:layout_width="100dip"
         android:layout_height="wrap_content" />

     <TextView android:id="@+id/last_name"
         android:layout_width="100dip"
         android:layout_height="wrap_content" />

     <TextView android:id="@+id/experience"
         android:layout_width="100dip"
         android:layout_height="wrap_content" />

     <TextView android:id="@+id/birthday"
         android:layout_width="100dip"
         android:layout_height="wrap_content">

</LinearLayout>

现在我需要得到所选行的每个字段的值。我正在努力

   ListView list = (ListView) findViewById(R.id.workers_list);
    list.setOnItemLongClickListener(new OnItemLongClickListener() {

            @Override
            public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                alert(parent.getItemAtPosition(position).toString()); // alert is Toast
                return true;
            }
        });
ListView列表=(ListView)findViewById(R.id.workers\u列表);
list.setOnItemLongClickListener(新的OnItemLongClickListener(){
@凌驾
公共布尔值长单击(AdapterView父项、视图、整型位置、长id){
警报(parent.getItemAtPosition(position.toString());//警报为Toast
返回true;
}
});
但它以有趣的(?)数据格式返回所有数据:
如何不获取行的所有数据,而只获取某些列的值?

getItemAtPosition
返回该位置的映射。所以你可以

((Map)parent.getItemAtPosition(position)).get("birthday").toString()

如果您想使用表格,那么您可以使用表格布局

您能澄清您的问题吗?您是否询问是否可以检测列表项中的哪个“列”被长按,或者只是询问如何访问您使用
getItemAtPosition()
检索的模型对象中的特定字段?您是否可以发布您正在使用的适配器类型,可能您所需要做的就是更改tostring方法。我不希望在parent.getItemAtPosition(position.tostring()中的图片处使用数组。我想要像parent.getItemAtPosition(position).getString(“生日”),它将返回“Бааааажааа”,或者parent.getItemAtPosition(position).getString(“名字”),它将返回“аааааааааааа,当然WorkersListAdapter=新的SimpleAdapter(此,WorkersArrayList,R.layout.listview_行,新字符串[]{“名字”、“姓氏”、“经验”、“生日”、“工作”、“学位”、“学术头衔”、“职务”},新整数[]{R.id.first_name,R.id.last_name,R.id.experience,R.id.生日,R.id.job,R.id.academic_degree,R.id.academic_title,R.id.operative_rank});list.setAdapter(workerslistapter);