3

editstudent.xml

  LinearLayout 

      ListView
           android:id="@android:id/list"        
      ListView

  LinearLayout

editstudentlist

  LinearLayout android:orientation="horizontal"  --  TOP Linear

       LinearLayout android:orientation="vertical"  -- sub Linear

           Tex0tView  android:id="@+id/enlist_tv_Name"  TextView

           TextView   android:id="@+id/enlist_tv_class" TextView

       LinearLayout -- sub Linear

       RadioButton  android:id="@+id/enList_rb_Id"   RadioButton

  LinearLayout --  TOP Linear

StudentActivity

StudentActivity extends ListActivity {

    setContentView(R.layout.editstudent);

    //get the data from database

    Cursor cursor = noMgr.getAllStudent();

    String[] columns= {StdentHelper.KEY_NAME,StdentHelper.KEY_CLASS, StdentHelper.KEY_ID};
    int[] to=new int[]{R.id.enlist_tv_name, R.id.enlist_tv_class, R.id.enList_rb_id};

    SimpleCursorAdapter scAdapter=new SimpleCursorAdapter(this, R.layout.editstudentlist, cursor, columns, to);

    this.setListAdapter(scAdapter);

} 

Here, there is a custom layout (editnumberlist.xml) with two text boxes and one radio button. It's been added to (editstudent.xml) using simpleCursorAdapter and it's working.

But I want the radio button to act like it's in the radio group (e.g. single selection at a time). Another question I have is how can I give the StudentHelper.KEY_ID to the radio button that should not be shown at runtime / execution time. Also how should I get the value of StudentHelper.KEY_ID in onListItemClick() function.

Does any one know how can I implement this?

4

0 回答 0