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


Java TextView.setId方法代碼示例

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


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

示例1: onCreateView

import android.widget.TextView; //導入方法依賴的package包/類
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Context context = getActivity();
    FrameLayout root = new FrameLayout(context);
    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(1);
    pframe.setVisibility(8);
    pframe.setGravity(17);
    pframe.addView(new ProgressBar(context, null, 16842874), new LayoutParams(-2, -2));
    root.addView(pframe, new LayoutParams(-1, -1));
    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);
    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(17);
    lframe.addView(tv, new LayoutParams(-1, -1));
    ListView lv = new ListView(getActivity());
    lv.setId(16908298);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new LayoutParams(-1, -1));
    root.addView(lframe, new LayoutParams(-1, -1));
    root.setLayoutParams(new LayoutParams(-1, -1));
    return root;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:25,代碼來源:ListFragment.java

示例2: initViews

import android.widget.TextView; //導入方法依賴的package包/類
private void initViews(Context context) {
            final int margin1X = context.getResources().getDimensionPixelSize(R.dimen.margin_1x);
            final int margin3X = context.getResources().getDimensionPixelSize(R.dimen.margin_3x);
            
            textView = new TextView(context);
            textView.setId(R.id.tab_text);
            textView.setGravity(Gravity.CENTER);
            textView.setPadding(margin3X, margin1X, margin3X, margin1X);
            textView.setMaxLines(1);
            textView.setEllipsize(TextUtils.TruncateAt.END);
            addView(textView);
    
//            bubbleView = new BubbleView(context);
//            bubbleView.setId(R.id.tab_bubble);
//            bubbleView.setBubbleCount(11);
//            addView(bubbleView);
            
            ViewGroup.LayoutParams lp = getLayoutParams();
            if (null == lp) {
                lp = new LinearLayout.LayoutParams(
                        ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.MATCH_PARENT,
                        1);
                setLayoutParams(lp);
            }
        }
 
開發者ID:ImDobyDad,項目名稱:SingleSelectBar,代碼行數:27,代碼來源:SingleSelectBar.java

示例3: setTabLayoutContentDescriptions

import android.widget.TextView; //導入方法依賴的package包/類
private void setTabLayoutContentDescriptions() {
    LayoutInflater inflater = getLayoutInflater();
    int gap = mDayZeroAdapter == null ? 0 : 1;
    for (int i = 0, count = mTabLayout.getTabCount(); i < count; i++) {
        TabLayout.Tab tab = mTabLayout.getTabAt(i);
        TextView view = (TextView) inflater.inflate(R.layout.tab_my_schedule, mTabLayout, false);
        view.setId(baseTabViewId + i);
        view.setText(tab.getText());
        if (i == 0) {
            view.setContentDescription(
                    getString(R.string.talkback_selected,
                            getString(R.string.a11y_button, tab.getText())));
        } else {
            view.setContentDescription(
                    getString(R.string.a11y_button, tab.getText()));
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            view.announceForAccessibility(
                    getString(R.string.my_schedule_tab_desc_a11y, getDayName(i - gap)));
        }
        tab.setCustomView(view);
    }
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:24,代碼來源:MyScheduleActivity.java

示例4: setCounterEnabled

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * Whether the character counter functionality is enabled or not in this layout.
 *
 * @attr ref android.support.design.R.styleable#TextInputLayout_counterEnabled
 */
public void setCounterEnabled(boolean enabled) {
  if (mCounterEnabled != enabled) {
    if (enabled) {
      mCounterView = new TextView(getContext());
      mCounterView.setId(R.id.textinput_counter);
      if (mTypeface != null) {
        mCounterView.setTypeface(mTypeface);
      }
      mCounterView.setMaxLines(1);
      try {
        TextViewCompat.setTextAppearance(mCounterView, mCounterTextAppearance);
      } catch (Exception e) {
        // Probably caused by our theme not extending from Theme.Design*. Instead
        // we manually set something appropriate
        TextViewCompat.setTextAppearance(
            mCounterView, android.R.style.TextAppearance_Material_Caption);
        mCounterView.setTextColor(
            ContextCompat.getColor(getContext(), R.color.design_textinput_error_color_light));
      }
      addIndicator(mCounterView, -1);
      if (mEditText == null) {
        updateCounter(0);
      } else {
        updateCounter(mEditText.getText().length());
      }
    } else {
      removeIndicator(mCounterView);
      mCounterView = null;
    }
    mCounterEnabled = enabled;
  }
}
 
開發者ID:commonsguy,項目名稱:cwac-crossport,代碼行數:38,代碼來源:TextInputLayout.java

示例5: UploadView

import android.widget.TextView; //導入方法依賴的package包/類
public UploadView(Context context, String uploadId, Bitmap bm, String title, String statusText, String pText, int progress) {
	super(context);
	
	idView = new TextView(context);
	idView.setVisibility(View.GONE);
	idView.setText(uploadId + "");

	imageView = new ImageView(context);
	imageView.setImageBitmap(bm);
	imageView.setBackgroundColor(0xFF666666);
	imageView.setId(VIDEOIMAGE_ID);
	
	titleView = new TextView(context);
	titleView.setText(title);
	titleView.setTextColor(0xFF000000);
	titleView.setId(TITLEVIEW_ID);
	titleView.setPaddingRelative(5, 5, 0, 0);
	
	statusTextView = new TextView(context);
	statusTextView.setText(statusText);
	statusTextView.setTextColor(0xFF000000);
	statusTextView.setId(STATUSVIEW_ID);
	statusTextView.setPaddingRelative(5, 5, 0, 0);
	statusTextView.setTextColor(Color.GRAY);
	
	progressTextView = new TextView(context);
	progressTextView.setText(pText);
	progressTextView.setTextColor(0xFF000000);
	progressTextView.setId(PROGRESSTEXT_ID);
	progressTextView.setPaddingRelative(5, 5, 0, 0);
	progressTextView.setTextColor(Color.GRAY);
	
	progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
	progressBar.setMax(100);
	progressBar.setIndeterminate(false);
       progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar));
       progressBar.setId(PROGRESSBAR_ID);
       progressBar.setPaddingRelative(5, 0, 0, 0);
       progressBar.setProgress(progress);
       
       /**
        *  
        *  + + + +  title
        *  + img +  0M / 0M
        *  +     +  下載中
        *  + + + +  ********progress**************
        *  
        * */
       //左側
       LayoutParams imageLayoutParams = new LayoutParams(ParamsUtil.dpToPx(context, 75), ParamsUtil.dpToPx(context, 75));
	imageLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
	
	//位於圖片右側
	LayoutParams titleLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	titleLayoutParams.addRule(RelativeLayout.RIGHT_OF, VIDEOIMAGE_ID);
	
	//位於標題下方
	LayoutParams statusLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	statusLayoutParams.addRule(RelativeLayout.BELOW, TITLEVIEW_ID);
	statusLayoutParams.addRule(RelativeLayout.RIGHT_OF, VIDEOIMAGE_ID);
	
	//位於狀態下方
	LayoutParams progressTextParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	progressTextParams.addRule(RelativeLayout.BELOW, STATUSVIEW_ID);
	progressTextParams.addRule(RelativeLayout.RIGHT_OF, VIDEOIMAGE_ID);
	
	//位於圖片左側,進度文本下方
       LayoutParams progressBarLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, ParamsUtil.dpToPx(context, 7));
       progressBarLayoutParams.addRule(RelativeLayout.RIGHT_OF, VIDEOIMAGE_ID);
       progressBarLayoutParams.addRule(RelativeLayout.BELOW, PROGRESSTEXT_ID);
       progressBarLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
       
	addView(imageView, imageLayoutParams);
	addView(titleView, titleLayoutParams);
	addView(statusTextView, statusLayoutParams);
	addView(progressTextView, progressTextParams);
	addView(progressBar, progressBarLayoutParams);
	setPadding(5, 5, 5, 5);

}
 
開發者ID:lbbniu,項目名稱:CCDownload,代碼行數:81,代碼來源:UploadView.java

示例6: createClassicViews

import android.widget.TextView; //導入方法依賴的package包/類
static void createClassicViews(RelativeLayout layout) {
    TextView textViewTitle = new TextView(layout.getContext());
    textViewTitle.setId(me.dkzwm.widget.srl.ext.classic.R.id.sr_classic_title);
    textViewTitle.setTextSize(12);
    textViewTitle.setTextColor(Color.parseColor("#333333"));
    TextView textViewLastUpdate = new TextView(layout.getContext());
    textViewLastUpdate.setId(me.dkzwm.widget.srl.ext.classic.R.id.sr_classic_last_update);
    textViewLastUpdate.setTextSize(10);
    textViewLastUpdate.setTextColor(Color.parseColor("#969696"));
    textViewLastUpdate.setVisibility(View.GONE);
    LinearLayout textContainer = new LinearLayout(layout.getContext());
    textContainer.setOrientation(LinearLayout.VERTICAL);
    textContainer.setGravity(Gravity.CENTER_HORIZONTAL);
    textContainer.setId(me.dkzwm.widget.srl.ext.classic.R.id.sr_classic_text_container);
    LinearLayout.LayoutParams textViewTitleLP = new LinearLayout.LayoutParams(ViewGroup
            .LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    textContainer.addView(textViewTitle, textViewTitleLP);
    LinearLayout.LayoutParams textViewLastUpdateLP = new LinearLayout.LayoutParams(ViewGroup
            .LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    textContainer.addView(textViewLastUpdate, textViewLastUpdateLP);
    RelativeLayout.LayoutParams textContainerLP = new RelativeLayout.LayoutParams(ViewGroup
            .LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    textContainerLP.addRule(RelativeLayout.CENTER_IN_PARENT);
    layout.addView(textContainer, textContainerLP);
    ImageView imageViewArrow = new ImageView(layout.getContext());
    imageViewArrow.setId(me.dkzwm.widget.srl.ext.classic.R.id.sr_classic_arrow);
    RelativeLayout.LayoutParams imageViewArrowLP = new RelativeLayout.LayoutParams(ViewGroup
            .LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    final int dp6 = PixelUtl.dp2px(layout.getContext(), 6);
    imageViewArrowLP.setMargins(dp6, dp6, dp6, dp6);
    imageViewArrowLP.addRule(RelativeLayout.LEFT_OF, me.dkzwm.widget.srl.ext.classic.R.id
            .sr_classic_text_container);
    imageViewArrowLP.addRule(RelativeLayout.CENTER_VERTICAL);
    layout.addView(imageViewArrow, imageViewArrowLP);
    ProgressBar progressBar = new ProgressBar(layout.getContext(), null, android.R.attr
            .progressBarStyleSmallInverse);
    progressBar.setId(me.dkzwm.widget.srl.ext.classic.R.id.sr_classic_progress);
    RelativeLayout.LayoutParams progressBarLP = new RelativeLayout.LayoutParams(ViewGroup
            .LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    progressBarLP.setMargins(dp6, dp6, dp6, dp6);
    progressBarLP.addRule(RelativeLayout.LEFT_OF, me.dkzwm.widget.srl.ext.classic.R.id
            .sr_classic_text_container);
    progressBarLP.addRule(RelativeLayout.CENTER_VERTICAL);
    layout.addView(progressBar, progressBarLP);
}
 
開發者ID:dkzwm,項目名稱:SmoothRefreshLayout,代碼行數:46,代碼來源:ClassicConfig.java

示例7: addAction

import android.widget.TextView; //導入方法依賴的package包/類
private void addAction(String text, View.OnClickListener onClickListener,int id){
    TextView textView = new TextView(mContext);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT
            , DisplayUtil.dip2px(mContext,60)));
    textView.setGravity(Gravity.CENTER);
    textView.setText(text);
    textView.setId(id);
    textView.setOnClickListener(onClickListener);
    mContentLayout.addView(textView);
}
 
開發者ID:zuoweitan,項目名稱:Hitalk,代碼行數:11,代碼來源:CommentActionPopup.java

示例8: onCreateView

import android.widget.TextView; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final Context context = getContext();

    FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    mRecyclerContainer = new FrameLayout(context);
    mRecyclerContainer.setId(R.id.recycler_container_id);

    mStandardEmptyView = new TextView(context);
    mStandardEmptyView.setId(R.id.recycler_empty_id);
    mStandardEmptyView.setGravity(Gravity.CENTER);
    mStandardEmptyView.setVisibility(View.GONE);
    mRecyclerContainer.addView(mStandardEmptyView, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    mRecyclerView = new RecyclerView(context);
    mRecyclerView.setId(R.id.recycler);
    mRecyclerContainer.addView(mRecyclerView, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(mRecyclerContainer, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}
 
開發者ID:halohoop,項目名稱:AndroidDigIn,代碼行數:35,代碼來源:RecyclerFragment.java

示例9: init

import android.widget.TextView; //導入方法依賴的package包/類
private void init(Context context) {
	tvEmpty = new TextView(context);
	int tvEmptySize = getResources().getDimensionPixelSize(ResHelper.getResId(context, "dimen", "bbs_empty_view_txt_size"));
	tvEmpty.setTextSize(TypedValue.COMPLEX_UNIT_PX, tvEmptySize);
	int padding = ResHelper.dipToPx(context, 10);
	tvEmpty.setPadding(padding, padding, padding, padding);
	int tvEmptyColor = getResources().getColor(ResHelper.getColorRes(context, "bbs_empty_view_txt_color"));
	tvEmpty.setTextColor(tvEmptyColor);
	tvEmpty.setId(ResHelper.getIdRes(context, "tvEmpty"));

	ivEmpty = new ImageView(context);
	ivEmpty.setScaleType(ImageView.ScaleType.CENTER);

	LayoutParams rlp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	rlp.addRule(CENTER_IN_PARENT, TRUE);
	addView(tvEmpty, rlp);

	rlp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	rlp.addRule(CENTER_HORIZONTAL, TRUE);
	rlp.addRule(ABOVE, tvEmpty.getId());
	addView(ivEmpty, rlp);

	OnClickListener ocl = new OnClickListener() {
		public void onClick(View view) {
			tvEmpty.setClickable(false);
			ivEmpty.setClickable(false);
			if (onRefreshClickListener != null) {
				onRefreshClickListener.onClick(view);
			}
		}
	};
	tvEmpty.setClickable(false);
	ivEmpty.setClickable(false);
	tvEmpty.setOnClickListener(ocl);
	ivEmpty.setOnClickListener(ocl);
}
 
開發者ID:MobClub,項目名稱:BBSSDK-for-Android,代碼行數:37,代碼來源:EmptyView.java

示例10: getView

import android.widget.TextView; //導入方法依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    if (LayoutParams.MATCH_PARENT != mWidth) {
        mKeyWidth = (mWidth - 2 * mMarginCol - mPaddingLeft
                - mPaddingRight) / 3;
    }
    mKeyHeight = (mHeight - mTitleHeight - mPaddingTop - mPaddingBottom
            - 3 * mMarginRow) / 4;
    ImageButton buttonView = new ImageButton(mContext);
    buttonView.setScaleType(ScaleType.CENTER_INSIDE);
    buttonView.setLayoutParams(
            new AbsListView.LayoutParams(mKeyWidth, mKeyHeight));

    TextView textView = new TextView(mContext);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        textView.setTextColor(
                mContext.getResources().getColor(mNumColor));
    } else {
        textView.setTextColor(mNumColor);
    }
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mNumSize);
    textView.setGravity(Gravity.CENTER);
    textView.setLayoutParams(
            new AbsListView.LayoutParams(mKeyWidth, mKeyHeight));
    if (!mIsAudio) {
        buttonView.setSoundEffectsEnabled(false);
        textView.setSoundEffectsEnabled(false);
    }

    long id = getItemId(position);
    String key = (String) getItem(position);
    if (Constant.CONFIRM_BUTTON_ITEM_ID == id) {
        if (null != mDoneForeSelector && null != mDoneBgSelector) {
            setDoneKey(buttonView);
        } else {
            setDefaultDoneDelKey(textView);
            String doneKeyStr = mContext.getResources()
                    .getString(R.string.str_done);
            textView.setText(doneKeyStr);
            int doneKeyColor = mContext.getResources()
                    .getColor(R.color.btn_security_keyboard_done);

            textView.setTextColor(doneKeyColor);
            int doneBackGroundColor = mContext.getResources()
                    .getColor(R.color.bg_security_keyboard_title);
            textView.setBackgroundColor(doneBackGroundColor);
            textView.setTextSize(16);
            textView.setId((int) getItemId(position));
            textView.setOnClickListener(onPasswordButtonClickListener);
            return textView;
        }
    } else if (Constant.DELETE_BUTTON_ITEM_ID == id) {
        if (null != mDelForeSelector || null != mDelBgSelector) {
            setDelKey(buttonView);
        } else {
            textView.setText(key);
            setDefaultDoneDelKey(textView);
            textView.setId((int) getItemId(position));
            textView.setOnClickListener(onPasswordButtonClickListener);
            return textView;
        }
    } else {
        if (null != mNumForeSelectorArray) {
            setNumberKey(buttonView, (int) id);
        } else {
            setDefaultNumKey(textView, (int) id);
            textView.setId((int) getItemId(position));
            textView.setOnClickListener(onPasswordButtonClickListener);
            return textView;
        }
    }
    buttonView.setId((int) getItemId(position));
    buttonView.setOnClickListener(onPasswordButtonClickListener);
    return buttonView;
}
 
開發者ID:VigorousLiang,項目名稱:PWEditText-SafeKeyboard,代碼行數:77,代碼來源:SafetyKeyboard.java

示例11: initTwentyFourHourViews

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * 初始化添加課程點擊事件
 */
private void initTwentyFourHourViews() {
    initViewParams();
    for (int i = 1; i < 11; i++) {
        for (int j = 1; j <= 8; j++) {
            if (j == 1) {
                addTimeView(i);
            } else if (i % 2 == 0) {
                //i 節數 j  周數
                addDotView(i, j - 1);
                //可以點擊的TextView 用來添加課程
                TextView tx = new TextView(context);
                tx.setId((i - 1) * 7 + j);
                //相對布局參數
                RelativeLayout.LayoutParams rp = new RelativeLayout.LayoutParams(aveWidth, gridHeight * 2);
                //設置他們的相對位置
                if (j == 2) {
                    if (i > 1) {
                        rp.addRule(RelativeLayout.BELOW, (i - 3) * 7 + j);
                    }
                } else {
                    //字體樣式
                    tx.setTextAppearance(context, R.style.courseTableText);
                    rp.addRule(RelativeLayout.RIGHT_OF, (i - 1) * 7 + j - 1);
                    rp.addRule(RelativeLayout.ALIGN_TOP, (i - 1) * 7 + j - 1);
                    tx.setText("");
                }

                tx.setLayoutParams(rp);
                tx.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        //莫忘了計算點擊的時間時 加上開始時間
                        if (curClickView != null) {
                            curClickView.setBackground(null);
                            if (curClickView.getId() == v.getId()) {
                                curClickView = null;
                                Bundle bundle = new Bundle();
                                bundle.putInt("type", SyllabusItemActivity.ADD_COURSE);
                                bundle.putLong("lessonId", -3);
                                //跳轉到添加課程界麵
                                startActivityForResult(SyllabusItemActivity.class, bundle, Constants.REQUEST);
                                return;
                            }
                        }
                        curClickView = v;
                        //TODO 修改添加課表背景
                        curClickView.setBackground(getResources().getDrawable(R.drawable.add_course_bg));
                        curClickView.setAlpha((float) 0.5);
                    }
                });
                if (courseLayout != null) {
                    courseLayout.addView(tx);
                }
            }
        }
    }
}
 
開發者ID:NICOLITE,項目名稱:HutHelper,代碼行數:61,代碼來源:SyllabusFragment.java

示例12: onCreateView

import android.widget.TextView; //導入方法依賴的package包/類
/**
* Provide default implementation to return a simple list view. Subclasses
* can override to replace with their own layout. If doing so, the
* returned view hierarchy <em>must</em> have a ListView whose id
* is {@link android.R.id#list android.R.id.list} and can optionally
* have a sibling view id {@link android.R.id#empty android.R.id.empty}
* that is to be shown when the list is empty.
*
* <p>If you are overriding this method with your own custom content,
* consider including the standard layout {@link android.R.layout#list_content}
* in your layout file, so that you continue to retain all of the standard
* behavior of ListFragment. In particular, this is currently the only
* way to have the built-in indeterminant progress state be shown.
*/
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        final Context context = getActivity();

        FrameLayout root = new FrameLayout(context);

        // ------------------------------------------------------------------

        LinearLayout pframe = new LinearLayout(context);
        pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
        pframe.setOrientation(LinearLayout.VERTICAL);
        pframe.setVisibility(View.GONE);
        pframe.setGravity(Gravity.CENTER);

        ProgressBar progress = new ProgressBar(context, null,
                android.R.attr.progressBarStyleLarge);
        pframe.addView(progress, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

        root.addView(pframe, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        // ------------------------------------------------------------------

        FrameLayout lframe = new FrameLayout(context);
        lframe.setId(INTERNAL_LIST_CONTAINER_ID);

        TextView tv = new TextView(getActivity());
        tv.setId(INTERNAL_EMPTY_ID);
        tv.setGravity(Gravity.CENTER);
        lframe.addView(tv, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        ExpandableListView lv = new ExpandableListView(getActivity());
        lv.setId(android.R.id.list);
        lv.setDrawSelectorOnTop(false);
        lframe.addView(lv, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        root.addView(lframe, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        // ------------------------------------------------------------------

        root.setLayoutParams(new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        return root;
    }
 
開發者ID:ericberman,項目名稱:MyFlightbookAndroid,代碼行數:65,代碼來源:ExpandableListFragment.java

示例13: create

import android.widget.TextView; //導入方法依賴的package包/類
public static RelativeLayout create(Context context) {
	SizeHelper.prepare(context);

	RelativeLayout root = new RelativeLayout(context);
	root.setId(ResHelper.getIdRes(context, "rl_lv_item_bg"));
	AbsListView.LayoutParams params = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
			SizeHelper.fromPxWidth(95));
	root.setLayoutParams(params);
	int padding = SizeHelper.fromPxWidth(14);
	root.setPadding(padding, padding, padding, padding);
	root.setGravity(Gravity.CENTER_VERTICAL);
	root.setBackgroundColor(0xffffffff);

	AsyncImageView contactImage = new AsyncImageView(context);
	contactImage.setId(ResHelper.getIdRes(context, "iv_contact"));
	RelativeLayout.LayoutParams contactImageParams = new RelativeLayout.LayoutParams(SizeHelper.fromPxWidth(64),
			SizeHelper.fromPxWidth(64));
	contactImageParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
	contactImage.setLayoutParams(contactImageParams);
	contactImage.setScaleType(ScaleType.FIT_CENTER);
	root.addView(contactImage);

	LinearLayout wrapper = new LinearLayout(context);
	RelativeLayout.LayoutParams wrapperParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
			RelativeLayout.LayoutParams.WRAP_CONTENT);
	wrapperParams.addRule(RelativeLayout.RIGHT_OF, ResHelper.getIdRes(context, "iv_contact"));
	wrapperParams.addRule(RelativeLayout.CENTER_VERTICAL);
	wrapperParams.leftMargin = SizeHelper.fromPxWidth(12);
	wrapper.setLayoutParams(wrapperParams);
	wrapper.setOrientation(LinearLayout.VERTICAL);
	root.addView(wrapper);

	TextView name = new TextView(context);
	name.setId(ResHelper.getIdRes(context, "tv_name"));
	LinearLayout.LayoutParams nameParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	name.setLayoutParams(nameParams);
	name.setTextColor(0xff333333);
	name.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(28));
	wrapper.addView(name);

	TextView contact = new TextView(context);
	contact.setId(ResHelper.getIdRes(context, "tv_contact"));
	LinearLayout.LayoutParams contactParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	contact.setLayoutParams(contactParams);
	contact.setTextColor(0xff999999);
	contact.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(22));
	wrapper.addView(contact);

	Button add = new Button(context);
	add.setId(ResHelper.getIdRes(context, "btn_add"));
	RelativeLayout.LayoutParams addParams = new RelativeLayout.LayoutParams(SizeHelper.fromPxWidth(92),
			SizeHelper.fromPxWidth(46));
	addParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	addParams.addRule(RelativeLayout.CENTER_VERTICAL);
	add.setLayoutParams(addParams);
	int resid = ResHelper.getStringRes(context, "smssdk_add_contact");
	add.setText(resid);
	add.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(22));
	add.setTextColor(0xff797979);
	//resid = R.getBitmapRes(context, "smssdk_corners_bg");
	add.setBackgroundDrawable(DrawableHelper.createCornerBg(context));
	add.setPadding(0, 0, 0, 0);
	root.addView(add);

	return root;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:69,代碼來源:ContactsListviewItemLayout.java

示例14: DownloadView

import android.widget.TextView; //導入方法依賴的package包/類
public DownloadView(Context context, String title, String statusInfo, String progressText, int progress) {
	super(context);
	
	titleView = new TextView(context);
	titleView.setText(title);
	titleView.setTextColor(0xFF000000);
	titleView.setId(TITLEVIEW_ID);
	titleView.setTextSize(15);
	titleView.setSingleLine();
	
	statusInfoView = new TextView(context);
	statusInfoView.setText(statusInfo);
	statusInfoView.setId(STATUSVIEW_ID);
	statusInfoView.setTextColor(0xFF000000);
	
	progressTextView = new TextView(context);
	progressTextView.setTextColor(0xFF000000);
	progressTextView.setId(PROGRESSTEXT_ID);
	progressTextView.setPadding(0, 10, 0, 0);
	progressTextView.setText(progressText);
	progressTextView.setTextColor(Color.GRAY);
	
	progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
	
	progressBar.setMax(100);
	progressBar.setMinimumHeight(10);
	progressBar.setIndeterminate(false);
       progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar));
       progressBar.setPadding(0, 10, 0, 0);
       progressBar.setProgress(progress);
	
	 /**
        *  
        *  title               
        *  下載中
        *  0M / 0M                
        *  ********progress**************
        *  
        * */
	
	LayoutParams titleLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	titleLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
	addView(titleView, titleLayoutParams);
	
	LayoutParams statusInfoLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	statusInfoLayoutParams.addRule(RelativeLayout.BELOW, TITLEVIEW_ID);
	statusInfoLayoutParams.addRule(RelativeLayout.ALIGN_LEFT, TITLEVIEW_ID);
	addView(statusInfoView, statusInfoLayoutParams);
	
	LayoutParams progressTextLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	progressTextLayoutParams.addRule(RelativeLayout.BELOW, STATUSVIEW_ID);
	progressTextLayoutParams.addRule(RelativeLayout.ALIGN_LEFT, TITLEVIEW_ID);
	addView(progressTextView, progressTextLayoutParams);
	
	LayoutParams progressLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, 25);
	progressLayoutParams.addRule(RelativeLayout.BELOW, PROGRESSTEXT_ID);
	progressLayoutParams.addRule(RelativeLayout.ALIGN_LEFT, TITLEVIEW_ID);
	addView(progressBar, progressLayoutParams);
	
	setPadding(5, 5, 5, 5);
}
 
開發者ID:lbbniu,項目名稱:CCDownload,代碼行數:62,代碼來源:DownloadView.java

示例15: initView

import android.widget.TextView; //導入方法依賴的package包/類
private void initView(Context context) {
    RelativeLayout pointContainerRl = new RelativeLayout(context);
    if (Build.VERSION.SDK_INT >= 16) {
        pointContainerRl.setBackground(mPointContainerBackgroundDrawable);
    } else {
        pointContainerRl.setBackgroundDrawable(mPointContainerBackgroundDrawable);
    }
    pointContainerRl.setPadding(mPointContainerLeftRightPadding, mPointTopBottomMargin, mPointContainerLeftRightPadding, mPointTopBottomMargin);
    LayoutParams pointContainerLp = new LayoutParams(RMP, RWC);
    // 處理圓點在頂部還是底部
    if ((mPointGravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.TOP) {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    } else {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    }
    addView(pointContainerRl, pointContainerLp);


    LayoutParams indicatorLp = new LayoutParams(RWC, RWC);
    indicatorLp.addRule(CENTER_VERTICAL);
    if (mIsNumberIndicator) {
        mNumberIndicatorTv = new TextView(context);
        mNumberIndicatorTv.setId(R.id.banner_indicatorId);
        mNumberIndicatorTv.setGravity(Gravity.CENTER_VERTICAL);
        mNumberIndicatorTv.setSingleLine(true);
        mNumberIndicatorTv.setEllipsize(TextUtils.TruncateAt.END);
        mNumberIndicatorTv.setTextColor(mNumberIndicatorTextColor);
        mNumberIndicatorTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mNumberIndicatorTextSize);
        mNumberIndicatorTv.setVisibility(View.INVISIBLE);
        if (mNumberIndicatorBackground != null) {
            if (Build.VERSION.SDK_INT >= 16) {
                mNumberIndicatorTv.setBackground(mNumberIndicatorBackground);
            } else {
                mNumberIndicatorTv.setBackgroundDrawable(mNumberIndicatorBackground);
            }
        }
        pointContainerRl.addView(mNumberIndicatorTv, indicatorLp);
    } else {
        mPointRealContainerLl = new LinearLayout(context);
        mPointRealContainerLl.setId(R.id.banner_indicatorId);
        mPointRealContainerLl.setOrientation(LinearLayout.HORIZONTAL);
        mPointRealContainerLl.setGravity(Gravity.CENTER_VERTICAL);
        pointContainerRl.addView(mPointRealContainerLl, indicatorLp);
    }

    LayoutParams tipLp = new LayoutParams(RMP, RWC);
    tipLp.addRule(CENTER_VERTICAL);
    mTipTv = new TextView(context);
    mTipTv.setGravity(Gravity.CENTER_VERTICAL);
    mTipTv.setSingleLine(true);
    mTipTv.setEllipsize(TextUtils.TruncateAt.END);
    mTipTv.setTextColor(mTipTextColor);
    mTipTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTipTextSize);
    pointContainerRl.addView(mTipTv, tipLp);

    int horizontalGravity = mPointGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
    // 處理圓點在左邊、右邊還是水平居中
    if (horizontalGravity == Gravity.LEFT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        tipLp.addRule(RelativeLayout.RIGHT_OF, R.id.banner_indicatorId);
        mTipTv.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    } else if (horizontalGravity == Gravity.RIGHT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    } else {
        indicatorLp.addRule(RelativeLayout.CENTER_HORIZONTAL);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    }

    showPlaceholder();
}
 
開發者ID:devzwy,項目名稱:KUtils,代碼行數:72,代碼來源:BGABanner.java


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