我是安卓新手。我正在开发一个应用程序,其中有一个带有编辑和删除按钮的学生列表视图。像
STUDENT LIST[ABC] [编辑] [删除]
[DEF] [编辑] [删除]
使用此代码,我可以在<Textview>
public class DataBaseDemoActivity extends ListActivity {
/** Called when the activity is first created. */
  SQLiteDatabase db;
  Button btnInsert;
  ArrayAdapter<String> students;
  @Override
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  try{
  db=openOrCreateDatabase("StudentDB",SQLiteDatabase.CREATE_IF_NECESSARY,null);
  Cursor c=db.rawQuery("SELECT * FROM temp",null);
  String[] students = new String[c.getCount()];
  if (c.moveToFirst())
  {                       
      for (int i = 0; i < c.getCount(); i++)
      {
          students[i] = c.getString(0).toString()+" "+c.getString(1).toString();
          c.moveToNext();
      }           
  }
  c.close();
  setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, students));
  ListView lv = getListView();
  lv.setTextFilterEnabled(true);
  lv.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view,
        int position, long id) {
      // When clicked, show a toast with the TextView text
      Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
          Toast.LENGTH_SHORT).show();
    }
  });
  }catch(SQLException e)
  {
  }
}
}
我需要将记录的 ID 存储在列表视图中,这样当我单击编辑或删除按钮时,我必须找出 ID 并在数据库上进行更改。我如何将值设置为两个字段,例如<TextView>[显示详细信息] 和<EditText>[可见性:不可见 - 保存记录的 id]。我可以<TextView>使用上面的代码获取详细信息。任何建议将不胜感激。
更新 :
我正在使用的布局
    <?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>