List of usage examples for android.widget TextView setCompoundDrawablesWithIntrinsicBounds
@android.view.RemotableViewMethod public void setCompoundDrawablesWithIntrinsicBounds(@Nullable Drawable left, @Nullable Drawable top, @Nullable Drawable right, @Nullable Drawable bottom)
From source file:net.alexjf.tmm.fragments.ImmedTransactionDetailsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_immedtransaction_details, container, false); detailsListView = (ListView) v.findViewById(android.R.id.list); adapter = new TwoLineTextAdapter<TransactionDetails>(getActivity()) { public void setTitleText(TextView titleTextView, TransactionDetails item) { titleTextView.setText(item.label); }/* w w w. j av a 2s . c o m*/ public void setValueText(TextView valueTextView, TransactionDetails item) { valueTextView.setText(item.value); valueTextView.setCompoundDrawablesWithIntrinsicBounds(item.leftDrawableId, 0, 0, 0); if (item.valueColor == null) { valueTextView.setTextColor(valueTextView.getTextColors().getDefaultColor()); } else { valueTextView.setTextColor(item.valueColor); } } ; }; detailsListView.setAdapter(adapter); return v; }
From source file:com.collabora.xwperf.notxw_contacts.fragments.MainFragment.java
private TabHost.TabSpec newTab(String tabId, String tabCaption, int imgResId) { TabHost.TabSpec tabSpec = tabHost.newTabSpec(tabId); ViewGroup tab = (ViewGroup) getLayoutInflater(Bundle.EMPTY).inflate(R.layout.view_tabwidget_tab, null); TextView tabTextView = ((TextView) tab.findViewById(R.id.tab_text)); tabTextView.setText(tabCaption);/*www .j a v a2 s .c o m*/ tabTextView.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(imgResId), null, null, null); tabSpec.setIndicator(tab); tabSpec.setContent(getContainerViewId(tabId)); return tabSpec; }
From source file:br.com.testmaster.view.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle(getResources().getString(R.string.main_activity_title)); setSupportActionBar(toolbar);/* ww w.j a va 2s . com*/ tabLayout = (TabLayout) findViewById(R.id.tabs); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.addDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); //Para evitar o uso de ViewPager //--------------------------------------------------------------------------------------------- TextView tabOffer = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null); tabOffer.setText("Disponveis"); tabOffer.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.ic_basket, 0, 0, 0); TextView tabLead = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null); tabLead.setText("Aceitos"); tabLead.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.ic_check, 0, 0, 0); //create tabs title tabLayout.addTab(tabLayout.newTab().setCustomView(tabOffer)); tabLayout.addTab(tabLayout.newTab().setCustomView(tabLead)); //replace default fragment replaceFragment(new OffersFragment()); //handling tab click event tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { if (tab.getPosition() == 0) { replaceFragment(new OffersFragment()); } else if (tab.getPosition() == 1) { replaceFragment(new LeadsFragment()); } } @Override public void onTabUnselected(TabLayout.Tab tab) { } @Override public void onTabReselected(TabLayout.Tab tab) { } }); }
From source file:nl.privacybarometer.privacyvandaag.adapter.FeedsCursorAdapter.java
@Override protected void bindGroupView(View view, Context context, Cursor cursor, boolean isExpanded) { ImageView indicatorImage = (ImageView) view.findViewById(R.id.indicator); if (cursor.getInt(mIsGroupPos) == 1) { indicatorImage.setVisibility(View.VISIBLE); TextView textView = ((TextView) view.findViewById(android.R.id.text1)); textView.setEnabled(true);/*from w w w . j av a 2 s.c om*/ textView.setText(cursor.getString(mNamePos)); textView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); textView.setText(cursor.getString(mNamePos)); if (isExpanded) indicatorImage.setImageResource(R.drawable.group_expanded); else indicatorImage.setImageResource(R.drawable.group_collapsed); } else { bindChildView(view, context, cursor); indicatorImage.setVisibility(View.GONE); } }
From source file:com.nadmm.airports.utils.UiUtils.java
public static void setRunwayDrawable(Context context, TextView tv, String runwayId, int length, int heading) { int resid;/*from w ww . ja v a 2 s. c o m*/ if (runwayId.startsWith("H")) { resid = R.drawable.helipad; } else { if (length > 10000) { resid = R.drawable.runway9; } else if (length > 9000) { resid = R.drawable.runway8; } else if (length > 8000) { resid = R.drawable.runway7; } else if (length > 7000) { resid = R.drawable.runway6; } else if (length > 6000) { resid = R.drawable.runway5; } else if (length > 5000) { resid = R.drawable.runway4; } else if (length > 4000) { resid = R.drawable.runway3; } else if (length > 3000) { resid = R.drawable.runway2; } else if (length > 2000) { resid = R.drawable.runway1; } else { resid = R.drawable.runway0; } } Drawable d = UiUtils.getRotatedDrawable(context, resid, heading); tv.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null); tv.setCompoundDrawablePadding(UiUtils.convertDpToPx(context, 5)); }
From source file:eu.trentorise.smartcampus.communicator.custom.MainAdapter.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { //View view = null; ViewHolder holder = new ViewHolder(); if (convertView == null) { if (position == 0) { Integer unread = null; holder.view = ((LayoutInflater) context.getSystemService(Service.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.tumb_view, null); int resource = R.drawable.inbox; String txt = null;//from w ww . ja va 2s . c om if ((unread = CommunicatorHelper.getUnreadCount()) != null) { if (unread > 0) { resource = R.drawable.inbox_alert; txt = "" + unread; } } else { new UpdateReadCountTask(holder.view).execute(); } ((TextView) holder.view.findViewById(R.id.numberView)).setText(txt); holder.view.findViewById(R.id.containerView).setBackgroundResource(resource); } else { TextView tmp = new TextView(context); tmp.setBackgroundColor(context.getResources().getColor(android.R.color.transparent)); tmp.setCompoundDrawablesWithIntrinsicBounds(null, context.getResources().getDrawable(ACTIONS[position].thumbnail), null, null); tmp.setText(ACTIONS[position].description); tmp.setTextColor(context.getResources().getColor(R.color.sc_dark_gray)); tmp.setGravity(Gravity.CENTER); holder.view = tmp; } holder.view.setOnClickListener(new CommunicatorOnClickListener(position)); } else { holder.view = convertView; if (position == 0) { Integer unread = null; holder.view = ((LayoutInflater) context.getSystemService(Service.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.tumb_view, null); int resource = R.drawable.inbox; String txt = null; if ((unread = CommunicatorHelper.getUnreadCount()) != null) { if (unread > 0) { resource = R.drawable.inbox_alert; txt = "" + unread; } } else { new UpdateReadCountTask(holder.view).execute(); } ((TextView) holder.view.findViewById(R.id.numberView)).setText(txt); holder.view.findViewById(R.id.containerView).setBackgroundResource(resource); } else { TextView tmp = new TextView(context); tmp.setBackgroundColor(context.getResources().getColor(android.R.color.transparent)); tmp.setCompoundDrawablesWithIntrinsicBounds(null, context.getResources().getDrawable(ACTIONS[position].thumbnail), null, null); tmp.setText(ACTIONS[position].description); tmp.setTextColor(context.getResources().getColor(R.color.sc_dark_gray)); tmp.setGravity(Gravity.CENTER); holder.view = tmp; } holder.view.setOnClickListener(new CommunicatorOnClickListener(position)); } return holder.view; }
From source file:net.naonedbus.card.impl.TraficCard.java
private View createView(final LayoutInflater inflater, final ViewGroup root, final InfoTrafic infoTrafic) { final View view = inflater.inflate(R.layout.card_item_trafic_ligne, root, false); final TextView itemTitle = (TextView) view.findViewById(R.id.itemTitle); final TextView itemDate = (TextView) view.findViewById(R.id.itemDate); itemTitle.setText(infoTrafic.getIntitule()); itemDate.setText(infoTrafic.getDateFormated()); if (isCurrent(infoTrafic)) { itemDate.setCompoundDrawablesWithIntrinsicBounds(R.drawable.info_trafic_on, 0, 0, 0); } else {//from w w w . ja v a 2 s. co m itemDate.setCompoundDrawablesWithIntrinsicBounds(R.drawable.info_trafic_off, 0, 0, 0); } view.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { final Bundle bundle = new Bundle(); bundle.putParcelable(InfoTraficDetailFragment.PARAM_INFO_TRAFIC, infoTrafic); final DialogFragment dialogFragment = new InfoTraficDetailDialogFragment(); dialogFragment.setArguments(bundle); dialogFragment.show(getFragmentManager(), "InfoTraficDetailDialogFragment"); } }); return view; }
From source file:com.bytestemplar.tonedef.international.ButtonsFragment.java
public void updateButtons(int position) { LinearLayout ll_btn_container = (LinearLayout) getView().findViewById(R.id.buttons_container); if (ll_btn_container != null) { _current_position = position;/* w ww . ja v a 2s . c o m*/ CountryTones current_tones = CountryTonesRepository.getInstance().getCountryAtPosition(position); ll_btn_container.removeAllViewsInLayout(); // Update label TextView tv_name = (TextView) getView().findViewById(R.id.tv_countryname); tv_name.setText(current_tones.getName()); tv_name.setTypeface(UICustom.getInstance().getTypeface()); if (current_tones.getFlagDrawable() > 0) { tv_name.setCompoundDrawablesWithIntrinsicBounds(current_tones.getFlagDrawable(), 0, 0, 0); } // Generate buttons HashMap<String, ToneSequence> sequences = current_tones.getSequences(); for (Object o : sequences.entrySet()) { Map.Entry pair = (Map.Entry) o; String sequence_name = (String) pair.getKey(); final ToneSequence sequence = (ToneSequence) pair.getValue(); Button btn = new Button(ll_btn_container.getContext()); btn.setText(sequence_name); btn.setTypeface(UICustom.getInstance().getTypeface()); btn.setBackgroundResource(R.drawable.touchpadbutton); btn.setTextColor(Color.WHITE); btn.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: sequence.start(); v.setBackgroundResource(R.drawable.touchpadbutton_selected); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: sequence.stop(); v.setBackgroundResource(R.drawable.touchpadbutton); break; } return false; } }); btn.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); ll_btn_container.addView(btn); } } }
From source file:com.woodblockwithoutco.quickcontroldock.ui.ControlService.java
public void attachTemporaryView(Drawable icon, String appName) { LinearLayout l = new LinearLayout(getApplicationContext()); l.setGravity(Gravity.CENTER_VERTICAL); l.setOrientation(LinearLayout.HORIZONTAL); l.setPadding(NOTIFICATION_TOAST_PADDING_PX, NOTIFICATION_TOAST_PADDING_PX, NOTIFICATION_TOAST_PADDING_PX, NOTIFICATION_TOAST_PADDING_PX); l.setBackgroundResource(R.drawable.notification_toast_bg); TextView tv = new TextView(getApplicationContext()); tv.setGravity(Gravity.CENTER);/* w w w . ja va 2 s. c om*/ tv.setCompoundDrawablePadding(COMPOUND_DRAWABLE_PADDING_PX); tv.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); String notificationText = getString(R.string.notification_from) + "\n" + appName; tv.setText(notificationText); tv.setTextColor(COLOR_WHITE); l.addView(tv); Toast toast = new Toast(getApplicationContext()); toast.setView(l); toast.show(); }
From source file:org.odk.collect.android.adapters.IconMenuListAdapter.java
private void refreshView(IconMenuItem item, TextView convertView) { convertView.setText(item.getTextResId()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { convertView.setCompoundDrawablesRelativeWithIntrinsicBounds(item.getImageResId(), 0, 0, 0); } else {//from w w w . ja va2 s . c o m if (ViewCompat.getLayoutDirection(convertView) == ViewCompat.LAYOUT_DIRECTION_LTR) { convertView.setCompoundDrawablesWithIntrinsicBounds(item.getImageResId(), 0, 0, 0); } else { convertView.setCompoundDrawablesWithIntrinsicBounds(0, 0, item.getImageResId(), 0); } } }