Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 具有多个控件的Android listview_Java_Android_Xml_Listview - Fatal编程技术网

Java 具有多个控件的Android listview

Java 具有多个控件的Android listview,java,android,xml,listview,Java,Android,Xml,Listview,我是android新手。我正在开发一个应用程序,其中有一个带有编辑和删除按钮的学生列表视图。像 [美国广播公司][编辑][删除] [定义][编辑][删除] 有了这段代码,我可以在一个列表中列出学生的详细信息 } 我需要在列表视图中存储记录的id,以便在单击“编辑”或“删除”按钮时,我必须找到id并在数据库中进行更改。如何将值设置为两个字段,即[show details]和[visibility:Insible-保存记录id]。我可以使用上面的代码获得到的详细信息。如有任何建议,将不胜感激 更新:

我是android新手。我正在开发一个应用程序,其中有一个带有编辑和删除按钮的学生列表视图。像

[美国广播公司][编辑][删除]

[定义][编辑][删除]

有了这段代码,我可以在一个列表中列出学生的详细信息

}

我需要在列表视图中存储记录的id,以便在单击“编辑”或“删除”按钮时,我必须找到id并在数据库中进行更改。如何将值设置为两个字段,即[show details]和[visibility:Insible-保存记录id]。我可以使用上面的代码获得到的详细信息。如有任何建议,将不胜感激

更新:

我正在使用的布局

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"    
    >
    <EditText 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="invisible"
        android:inputType="text"
        android:onClick="showInfo"
        />
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="230dip"
        android:layout_height="wrap_content"
        android:textSize="16sp"
        android:id="@+id/studentInfo" >
    </TextView>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/action"
        android:onClick="showInfo"
         />

</LinearLayout>
在这一行之后

   students[i] = c.getString(0).toString()+" "+c.getString(1).toString();
    student_ids[i]=Integer.parseInt(//get the  id... )
  //and you dont need to put it in invisible edittext...
在onclick方法中,您将获得整型位置..,并在该位置的students_id[]中获得该值

 int id=students_ids[position];

您可以在游标数据获取循环中获取Id,对其使用任何HashMap集合,并将Id与数据文本一起存储

根据您的要求,我建议您在ListView中使用SimpleCorsorAdapter而不是ArrayAdapter

所以,您可以使用列表轻松地管理数据库记录,并且在单击列表项时还可以获取特定记录的所有数据库相关信息


记录的id表示带文本的数据库记录id?对吗?@user370305:我是指数据库记录的id。当我点击编辑按钮时,我将如何获得整数位置?。。你能告诉我…你的按钮不是listview行的一部分吗?是按钮在该行内。我已经更新了问题。。添加了我的布局。请查收。和
   students[i] = c.getString(0).toString()+" "+c.getString(1).toString();
    student_ids[i]=Integer.parseInt(//get the  id... )
  //and you dont need to put it in invisible edittext...
 int id=students_ids[position];