当前位置: 首页>>代码示例>>Java>>正文


Java Spinner.setDropDownWidth方法代码示例

本文整理汇总了Java中android.widget.Spinner.setDropDownWidth方法的典型用法代码示例。如果您正苦于以下问题:Java Spinner.setDropDownWidth方法的具体用法?Java Spinner.setDropDownWidth怎么用?Java Spinner.setDropDownWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.Spinner的用法示例。


在下文中一共展示了Spinner.setDropDownWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showCertificateChain

import android.widget.Spinner; //导入方法依赖的package包/类
private void showCertificateChain(byte[][] derData) {
    for (int i = 0; i < derData.length; i++) {
        addCertificate(derData[i]);
    }
    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(mContext,
            android.R.layout.simple_spinner_item,
            mTitles) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            TextView view = (TextView) super.getView(position, convertView, parent);
            // Add extra padding on the end side to avoid overlapping the dropdown arrow.
            ApiCompatibilityUtils.setPaddingRelative(view, mPadding, mPadding, mPadding * 2,
                    mPadding);
            return view;
        }
    };
    arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    LinearLayout dialogContainer = new LinearLayout(mContext);
    dialogContainer.setOrientation(LinearLayout.VERTICAL);

    TextView title = new TextView(mContext);
    title.setText(R.string.certtitle);
    ApiCompatibilityUtils.setTextAlignment(title, View.TEXT_ALIGNMENT_VIEW_START);
    ApiCompatibilityUtils.setTextAppearance(title, android.R.style.TextAppearance_Large);
    title.setTypeface(title.getTypeface(), Typeface.BOLD);
    title.setPadding(mPadding, mPadding, mPadding, mPadding / 2);
    dialogContainer.addView(title);

    Spinner spinner = new Spinner(mContext);
    ApiCompatibilityUtils.setTextAlignment(spinner, View.TEXT_ALIGNMENT_VIEW_START);
    spinner.setAdapter(arrayAdapter);
    spinner.setOnItemSelectedListener(this);
    spinner.setDropDownWidth(ViewGroup.LayoutParams.MATCH_PARENT);
    // Remove padding so that dropdown has same width as the spinner.
    spinner.setPadding(0, 0, 0, 0);
    dialogContainer.addView(spinner);

    LinearLayout certContainer = new LinearLayout(mContext);
    certContainer.setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < mViews.size(); ++i) {
        LinearLayout certificateView = mViews.get(i);
        if (i != 0) {
            certificateView.setVisibility(LinearLayout.GONE);
        }
        certContainer.addView(certificateView);
    }
    ScrollView scrollView = new ScrollView(mContext);
    scrollView.addView(certContainer);
    dialogContainer.addView(scrollView);

    showDialogForView(dialogContainer);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:54,代码来源:CertificateViewer.java


注:本文中的android.widget.Spinner.setDropDownWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。