當前位置: 首頁>>代碼示例>>Java>>正文


Java RadioGroup.LayoutParams方法代碼示例

本文整理匯總了Java中android.widget.RadioGroup.LayoutParams方法的典型用法代碼示例。如果您正苦於以下問題:Java RadioGroup.LayoutParams方法的具體用法?Java RadioGroup.LayoutParams怎麽用?Java RadioGroup.LayoutParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.RadioGroup的用法示例。


在下文中一共展示了RadioGroup.LayoutParams方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setAdapter

import android.widget.RadioGroup; //導入方法依賴的package包/類
/**
 * 設置適配器
 *
 * @param adapter 適配器
 */
public void setAdapter(NavAdapter adapter) {
    //動態生成菜單
    int pageCount = adapter.getCount();
    RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(RadioGroup.LayoutParams
            .WRAP_CONTENT, RadioGroup.LayoutParams.MATCH_PARENT, 1);
    //先移除所有的菜單項
    rgTabs.removeAllViews();
    for (int i = 0; i < pageCount; i++) {
        BGABadgeRadioButton tab = (BGABadgeRadioButton) LayoutInflater.from(getContext())
                .inflate(R.layout.view_nav_tab, null);
        tab.setLayoutParams(params);
        tab.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(adapter
                .getTabIconId(i)), null, null);
        tab.setText(adapter.getPageTitle(i));
        tab.setTextColor(mNavTextDefaultColor);
        tab.setTag(i);

        rgTabs.addView(tab, i);
    }

    //從適配器獲取頁麵緩存
    mCache = adapter.getPagerCache();

    //設置ViewPager適配器
    vpContent.setAdapter(adapter);

    //設置默認選中的菜單選項
    ((RadioButton) rgTabs.getChildAt(vpContent.getCurrentItem())).setChecked(true);
    //設置選中項樣式
    setTabStyle((RadioButton) rgTabs.getChildAt(vpContent.getCurrentItem()), true);

    //初始化事件
    initListener();

    //綁定適配器與BtgView,為了在適配器中能獲取到BtgView中的某些數據,比如當前頁麵
    adapter.bindTpgView(this);
}
 
開發者ID:yhyzgn,項目名稱:TabPager,代碼行數:43,代碼來源:NavView.java

示例2: addIndex

import android.widget.RadioGroup; //導入方法依賴的package包/類
/**
 * 添加指示器
 */
private void addIndex(){
    RadioGroup.LayoutParams layoutParams = new RadioGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(10,0,10,0);
    RadioButton radioButton = new RadioButton(getContext());
    radioButton.setLayoutParams(layoutParams);
    radioButton.setButtonDrawable(indicatorResId);
    radioButton.setEnabled(false);
    buttons.add(radioButton);
}
 
開發者ID:Militch,項目名稱:banner-holder,代碼行數:13,代碼來源:BannerHolderView.java

示例3: getRadios

import android.widget.RadioGroup; //導入方法依賴的package包/類
private static View getRadios(Activity activity, LayoutInflater inflater, final SignUpEventOptions options) {
    View view = inflater.inflate(R.layout.event_sign_up_radios, null);
    ((TextView) view.findViewById(R.id.tv_label)).setText(options.getLabel() + (options.isRequired() ? "" : "(選填)") + ":");
    RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.rg_options);
    RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMarginEnd(100);
    if (!TextUtils.isEmpty(options.getOption())) {
        String[] list = options.getOption().split(";");
        String[] status = null;
        if (!TextUtils.isEmpty(options.getOptionStatus()))
            status = options.getOptionStatus().split(";");
        for (int i = 0; i < list.length; i++) {
            RadioButton button = new RadioButton(activity);
            button.setLayoutParams(params);
            button.setText(list[i]);
            if (!TextUtils.isEmpty(options.getDefaultValue())) {
                button.setChecked(list[0].equals(options.getDefaultValue()));
                options.setValue(options.getDefaultValue());
            } else {
                button.setChecked(i == 0);
                options.setValue(list[0]);
            }
            boolean enable;
            if (status == null)
                enable = true;
            else if (status.length <= i)
                enable = true;
            else
                enable = "0".equals(status[0]);
            button.setId(i);
            button.setEnabled(enable);
            radioGroup.addView(button);
        }
    }
    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            String s[] = options.getOption().split(";");
            if (s != null)
                options.setValue(s[checkedId]);
        }
    });
    return view;
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:47,代碼來源:ViewFactory.java

示例4: getCheckBox

import android.widget.RadioGroup; //導入方法依賴的package包/類
private static View getCheckBox(Activity activity, LayoutInflater inflater, final SignUpEventOptions options) {
    View view = inflater.inflate(R.layout.event_sign_up_check_box, null);
    FlowLayout ll_check_box = (FlowLayout) view.findViewById(R.id.fl_check_box);
    ((TextView) view.findViewById(R.id.tv_label)).setText(options.getLabel() + (options.isRequired() ? "" : "(選填)") + ":");
    RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMarginEnd(100);
    if (options.getSelectList() == null)
        options.setSelectList(new ArrayList<String>());
    if (!TextUtils.isEmpty(options.getOption())) {
        final String[] list = options.getOption().split(";");
        String[] status = null;
        if (!TextUtils.isEmpty(options.getOptionStatus()))
            status = options.getOptionStatus().split(";");
        for (int i = 0; i < list.length; i++) {
            final CheckBox button = new CheckBox(activity);
            button.setLayoutParams(params);
            button.setText(list[i]);
            boolean enable;
            if (status == null)
                enable = true;
            else if (status.length <= i)
                enable = true;
            else
                enable = "0".equals(status[i]);
            button.setId(i);
            button.setEnabled(enable);
            button.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    String item = list[button.getId()];
                    if (isChecked) {
                        options.getSelectList().add(item);
                    } else {
                        options.getSelectList().remove(item);
                    }
                }
            });
            ll_check_box.addView(button);
        }
    }
    return view;
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:45,代碼來源:ViewFactory.java


注:本文中的android.widget.RadioGroup.LayoutParams方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。