protected void setRightButtonText(String text) { RelativeLayout rightView = (RelativeLayout) findViewById(R.id.right_view); rightView.removeAllViews(); int padding = dp2px(6); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); lp.addRule(RelativeLayout.CENTER_IN_PARENT); lp.setMargins(0, 0, dp2px(8), 0); TextView tv = new TextView(this); tv.setText(text); tv.setTextColor(0xFF666666); tv.setTextSize(16.f); tv.setLayoutParams(lp); tv.setBackgroundResource(R.drawable.btn_gray); tv.setPadding(2 * padding, padding, 2 * padding, padding); tv.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { onRightButtonClicked(v); } }); rightView.addView(tv); rightView.setVisibility(View.VISIBLE); }
/** 初始化Column栏目项 */ private void initTabColumn() { mRadioGroup_content.removeAllViews(); if (mUserChannelList != null) { int count = mUserChannelList.size(); mColumnHorizontalScrollView.setParam( getActivity(), mScreenWidth, mRadioGroup_content, mShadeleft, mShaderight, ll_more_columns, rl_column); for (int i = 0; i < count; i++) { LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.leftMargin = 5; params.rightMargin = 5; // TextView localTextView = (TextView) mInflater.inflate(R.layout.column_radio_item, // null); TextView columnTextView = new TextView(getActivity()); columnTextView.setTextAppearance(getActivity(), R.style.top_category_scroll_view_item_text); // // localTextView.setBackground(getResources().getDrawable(R.drawable.top_category_scroll_text_view_bg)); columnTextView.setBackgroundResource(R.drawable.radio_buttong_bg); columnTextView.setGravity(Gravity.CENTER); columnTextView.setPadding(5, 5, 5, 5); columnTextView.setId(i); columnTextView.setText(mUserChannelList.get(i).getName()); columnTextView.setTextColor( getResources().getColorStateList(R.color.top_category_scroll_text_color_day)); if (columnSelectIndex == i) { columnTextView.setSelected(true); } columnTextView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < mRadioGroup_content.getChildCount(); i++) { View localView = mRadioGroup_content.getChildAt(i); if (localView != v) localView.setSelected(false); else { localView.setSelected(true); mViewPager.setCurrentItem(i); } } Toast.makeText( getActivity().getApplicationContext(), mUserChannelList.get(v.getId()).getName(), Toast.LENGTH_SHORT) .show(); } }); mRadioGroup_content.addView(columnTextView, i, params); } } }
// if platform selected form platform gridview is SinaWeibo, // TencentWeibo, Facebook, or Twitter, there will be a button // in the left-bottom of the page, which provides At-friends function private LinearLayout getAtLine(String platform) { if (!isShowAtUserLayout(platform)) { return null; } LinearLayout llAt = new LinearLayout(getContext()); LayoutParams lpAt = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lpAt.rightMargin = dipToPx(getContext(), 4); lpAt.gravity = Gravity.LEFT | Gravity.BOTTOM; lpAt.weight = 1; llAt.setLayoutParams(lpAt); llAt.setOnClickListener( new OnClickListener() { public void onClick(View v) { if (platforms != null && platforms.size() > 0) { FollowListPage subPage = new FollowListPage(); subPage.setPlatform(platforms.get(0)); subPage.showForResult(activity, null, EditPage.this); } else { int resId = getStringRes(activity, "ssdk_oks_select_one_plat_at_least"); if (resId > 0) { Toast.makeText(getContext(), resId, Toast.LENGTH_SHORT).show(); } } } }); TextView tvAt = new TextView(getContext()); int resId = getBitmapRes(activity, "ssdk_oks_btn_back_nor"); if (resId > 0) { tvAt.setBackgroundResource(resId); } int dp_32 = dipToPx(getContext(), 32); tvAt.setLayoutParams(new LayoutParams(dp_32, dp_32)); tvAt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); tvAt.setText(getAtUserButtonText(platform)); int dp_2 = dipToPx(getContext(), 2); tvAt.setPadding(0, 0, 0, dp_2); tvAt.setTypeface(Typeface.DEFAULT_BOLD); tvAt.setTextColor(0xff000000); tvAt.setGravity(Gravity.CENTER); llAt.addView(tvAt); TextView tvName = new TextView(getContext()); tvName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); tvName.setTextColor(0xff000000); resId = getStringRes(activity, "ssdk_oks_list_friends"); String text = getContext().getString(resId, getName(platform)); tvName.setText(text); LayoutParams lpName = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lpName.gravity = Gravity.CENTER_VERTICAL; tvName.setLayoutParams(lpName); llAt.addView(tvName); return llAt; }
public void checkNotification() { int countNumberOfNotifications = 0; String numToString = ""; String user = BrainJuice.retrieveLoginUser(); BrainJuice.retrieveANMgr().retrieveAdultNotification(user); ArrayList<com.example.brainjuice.entity.AdultNotification> adultNotificationList; adultNotificationList = BrainJuice.retrieveANMgr().retrieveAdultNotification(user); for (com.example.brainjuice.entity.AdultNotification counter : adultNotificationList) { countNumberOfNotifications++; } numToString = Integer.toString(countNumberOfNotifications); if (countNumberOfNotifications <= 0) { textView = (TextView) findViewById(R.id.count); textView.setBackgroundResource(R.drawable.blank); notificationCount = (TextView) this.findViewById(R.id.count); notificationCount.setText(""); } else { textView = (TextView) findViewById(R.id.count); textView.setBackgroundResource(R.drawable.notificationred); notificationCount = (TextView) this.findViewById(R.id.count); notificationCount.setText(numToString); } }
@Override public View getView(int position, View convertView, ViewGroup parent) { convertView = mInflater.inflate(R.layout.renren_dialog_list_item, null); ((TextView) convertView).setText(getItem(position)); if (mSpecialItems.size() > 0 && mSpecialItems.contains(position)) { ((TextView) convertView) .setBackgroundResource(R.drawable.renren_dialog_list_special_item_bg_selector); ((TextView) convertView) .setTextColor( mContext .getResources() .getColorStateList(R.drawable.renren_dialog_list_special_item_text_selector)); } return convertView; }