Android RadioButton未显示在RadioGroup中

Android RadioButton未显示在RadioGroup中,android,radio-button,Android,Radio Button,我正在通过程序添加一些单选按钮,但它可能无法显示按钮 结果只能显示itemNameText和optcatext,单选按钮不显示。我想知道他们是否加入了广播组 下面是我的代码。故障在哪里 convertView = LayoutInflater.from(context).inflate(layout, parent, false); FoodItem item = this.getItem(position); TextView itemName

我正在通过程序添加一些单选按钮,但它可能无法显示按钮

结果只能显示
itemNameText
optcatext
,单选按钮不显示。我想知道他们是否加入了广播组

下面是我的代码。故障在哪里

        convertView = LayoutInflater.from(context).inflate(layout, parent, false);

        FoodItem item = this.getItem(position);
        TextView itemNameText = (TextView)convertView.findViewById(R.id.food_name);
        itemNameText.setText(item.getFoodInfo(db, EasyMealDB.FOOD_NAME));

        LinearLayout options = (LinearLayout)convertView.findViewById(R.id.options);
        String optCatSql = "SELECT "+EasyMealDB.FOOD_OPTION_CATEGORY_NAME+
                                ", "+EasyMealDB.FOOD_OPTION_CATEGORY_ID+
                            " FROM "+EasyMealDB.FOOD_OPTION_CATEGORY_TABLE+
                            " WHERE "+EasyMealDB.FOOD_ID+" = "+item.getId();
        Log.d(TAG, optCatSql);
        Cursor optCatCursor = db.rawQuery(optCatSql, null);
        while (optCatCursor.moveToNext()){
            TextView optCatText = new TextView(context);
            optCatText.setText(optCatCursor.getString(0)+":");

            options.addView(optCatText);

            RadioGroup radioGp = new RadioGroup(context);
            radioGp.setOrientation(RadioGroup.VERTICAL);
            String optSql = "SELECT "+EasyMealDB.FOOD_OPTION_NAME+
                        " FROM "+EasyMealDB.FOOD_OPTION_TABLE+
                        " WHERE "+EasyMealDB.FOOD_OPTION_CATEGORY_ID+" = "+optCatCursor.getInt(1);
            Log.d(TAG, optSql);
            Cursor optCursor = db.rawQuery(optSql, null);               
            while (optCursor.moveToNext()){
                RadioButton optionButton = new RadioButton(context);
                optionButton.setText(optCursor.getString(0));
                Log.d(TAG, optionButton.getText().toString());
                radioGp.addView(optionButton);
            }
            optCursor.close();
        }
        optCatCursor.close(); 

到目前为止,我可以看到,您尚未将您的RadioGroup添加到LinearLayout。有多种选择。添加视图(放射图);失踪……哦~一个粗心的错误!THX:)