从我的MainView
( ExpandableListView
) 我得到RadioButton
defined child_row.xml
,我设置了监听器,但OnCheckChanged
没有被调用。如果我移动RadioButton
到 currentview,它会被调用。
我怎样才能解决这个问题?
我有 ....
- mainListView.xml //可扩展列表视图
- group_row.xml //文本视图
- child_row.xml //有自定义radioButton
→
public class Main_ListView extends Activity implements OnCheckedChangeListener{
public void onCreate(Bundle savedInstanceState) {
try{
super.onCreate(savedInstanceState);
setContentView(R.layout.mainListView);
ExpandableListView elv = (ExpandableListView) findViewById(R.id.expandableListView1);
SimpleExpandableListAdapter expListAdapter =
new SimpleExpandableListAdapter(
getApplicationContext(),
createGroupList(), // Creating group List.
R.layout.group_row, // Group item layout XML.
new String[] { "Group Item" }, // the key of group item.
new int[] { R.id.row_name }, // ID of each group item.-Data under the key goes into this TextView.
createChildList(), // childData describes second-level entries.
R.layout.child_row, // Layout for sub-level entries(second level).
new String[] {"Sub Item"}, // Keys in childData maps to display.
new int[] { R.id.grp_child} // Data under the keys above go into these TextViews.
);
elv.setAdapter(expListAdapter); // setting the adapter in the list.
}catch(Exception e){
System.out.println("Errrr +++ " + e.getMessage());
}
final LayoutInflater factory = getLayoutInflater();
final View childview = factory.inflate(R.layout.child_row, null);
answersGroup = (SegmentedRadioGroup) childview.findViewById(R.id.answersGroup);
if(answersGroup != null)
answersGroup.setOnCheckedChangeListener(this);
}
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (group == answersGroup) {
if (checkedId == R.id.radio0) {
mToast.setText("One");
mToast.show();
} else if (checkedId == R.id.radio1) {
mToast.setText("Two");
mToast.show();
} else if (checkedId == R.id.radio2) {
mToast.setText("Three");
mToast.show();
}
}
}