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:org.yaaic.activity.MainActivity.java
public void updateDrawerServerList() { List<Server> servers = Yaaic.getInstance().getServers(); drawerEmptyView.setVisibility(servers.size() > 0 ? View.GONE : View.VISIBLE); serverContainer.removeAllViews();/*from ww w . j av a 2s.c o m*/ for (final Server server : servers) { TextView serverView = (TextView) getLayoutInflater().inflate(R.layout.item_drawer_server, drawer, false); serverView.setText(server.getTitle()); serverView.setCompoundDrawablesWithIntrinsicBounds( getDrawable(server.isConnected() ? R.drawable.ic_navigation_server_connected : R.drawable.ic_navigation_server_disconnected), null, null, null); int colorResource = server.isConnected() ? R.color.connected : R.color.disconnected; serverView.setTextColor(ContextCompat.getColor(this, colorResource)); serverView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onServerSelected(server); drawer.closeDrawers(); } }); serverContainer.addView(serverView, 0); } }
From source file:com.ridhofkr.hanacaraka.LetterCardActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* remove title bar and notification bar */ requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); /* end remove title bar and notification bar */ setContentView(R.layout.lettercard); ctrl = new LetterController(); category = ListingLettersActivity.CURRENT_CATEGORY; TextView text = (TextView) findViewById(R.id.headertext); text.setText("informasi huruf"); text.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.information_circle, 0); ctrl.makeListOfLetter();// w w w . ja v a2 s .c o m letters = getLetters(ListingLettersActivity.CURRENT_CATEGORY); int p = 0; for (int i = 0; i < letters.size(); i++) { if (letters.get(i).name.equals(ListingLettersActivity.CURRENT_TEXT)) p = i; } ICPagerAdapter adapter = new ICPagerAdapter(letters); ViewPager pager = (ViewPager) findViewById(R.id.icviewpager); pager.setAdapter(adapter); pager.setCurrentItem(p); }
From source file:com.nttec.everychan.ui.ShareActivity.java
private void handleIntent(Intent intent) { ArrayAdapter<Pair<TabModel, SerializablePage>> adapter = new ArrayAdapter<Pair<TabModel, SerializablePage>>( this, 0) { private final int drawablePadding = (int) (getResources().getDisplayMetrics().density * 5 + 0.5f); @Override//w w w . ja v a 2 s .c om public View getView(int position, View convertView, ViewGroup parent) { View view = convertView == null ? getLayoutInflater().inflate(android.R.layout.simple_list_item_1, parent, false) : convertView; TextView tv = (TextView) view.findViewById(android.R.id.text1); tv.setEllipsize(TextUtils.TruncateAt.END); tv.setSingleLine(); tv.setText(getItem(position).getLeft().title); tv.setCompoundDrawablesWithIntrinsicBounds(MainApplication.getInstance() .getChanModule(getItem(position).getLeft().pageModel.chanName).getChanFavicon(), null, null, null); tv.setCompoundDrawablePadding(drawablePadding); return view; } }; for (TabModel tab : MainApplication.getInstance().tabsState.tabsArray) { if (tab.type == TabModel.TYPE_NORMAL && tab.pageModel.type != UrlPageModel.TYPE_SEARCHPAGE) { SerializablePage page = MainApplication.getInstance().pagesCache.getSerializablePage(tab.hash); if (page != null) { adapter.add(Pair.of(tab, page)); } } } if (adapter.getCount() == 0) { for (Database.HistoryEntry entity : MainApplication.getInstance().database.getHistory()) { try { TabModel tab = new TabModel(); tab.title = entity.title; tab.type = TabModel.TYPE_NORMAL; tab.webUrl = entity.url; tab.pageModel = UrlHandler.getPageModel(entity.url); tab.hash = ChanModels.hashUrlPageModel(tab.pageModel); SerializablePage page = MainApplication.getInstance().pagesCache.getSerializablePage(tab.hash); if (page != null) { adapter.add(Pair.of(tab, page)); } } catch (Exception e) { Logger.e(TAG, e); } } if (adapter.getCount() == 0) { Toast.makeText(this, R.string.share_no_tabs, Toast.LENGTH_LONG).show(); finish(); return; } } if (PostingService.isNowPosting()) { Toast.makeText(this, R.string.posting_now_posting, Toast.LENGTH_LONG).show(); finish(); return; } selectedFile = null; if (intent != null) { Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (uri != null) { File file = UriFileUtils.getFile(this, uri); if (file != null) { selectedFile = file; } } } if (selectedFile == null) { Toast.makeText(this, R.string.postform_cannot_attach, Toast.LENGTH_LONG).show(); finish(); return; } setListAdapter(adapter); }
From source file:net.zionsoft.obadiah.ui.adapters.TranslationListAdapter.java
private View getTranslationView(int position, View convertView, ViewGroup parent) { final TextView textView = (TextView) (convertView == null ? mInflater.inflate(R.layout.item_translation, parent, false) : convertView);/*from w w w. j av a 2 s . c om*/ final TranslationInfoHolder translation = (TranslationInfoHolder) getItem(position); textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, translation.translationInfo.shortName.equals(mCurrentTranslation) ? R.drawable.ic_check : 0, 0); textView.setText(translation.title); textView.setTextColor(mTextColor); return textView; }
From source file:com.android.nsboc.ComposeFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == ComposeActivity.RESULT_OK) { if (requestCode == ComposeActivity.REQUEST_IMAGE_CAPTURE) { Bundle extras = data.getExtras(); Bitmap imageBitmap = (Bitmap) extras.get("data"); int selectorId = data.getIntExtra("image_selector_id", -1); if (selectorId != -1) { TextView selectorLabel = (TextView) mRootView.findViewById(selectorId); if (selectorLabel != null) { Drawable imagePreview = new BitmapDrawable(getResources(), imageBitmap); selectorLabel.setCompoundDrawablesWithIntrinsicBounds(imagePreview, null, null, null); }/*from ww w . j a v a2s. c o m*/ } } else if (requestCode == ComposeActivity.REQUEST_FROM_GALLERY || requestCode == ComposeActivity.REQUEST_SIGNATURE) { Uri imageUri = data.getData(); String imagePath = getPath(imageUri); Drawable imagePreview = Drawable.createFromPath(imagePath); int selectorId = data.getIntExtra("image_selector_id", -1); if (selectorId != -1) { TextView selectorLabel = (TextView) mRootView.findViewById(selectorId); if (selectorLabel != null) { selectorLabel.setCompoundDrawablesWithIntrinsicBounds(imagePreview, null, null, null); } } } } }
From source file:net.naonedbus.fragment.CustomCursorFragment.java
/** * Afficher un message avec une desciption et un symbole. * /*from w w w. j a v a2 s .c o m*/ * @param title * Le titre. * @param description * La description. * @param drawableRes * L'identifiant du symbole. */ protected void showMessage(final String title, final String description, final int drawableRes) { mFragmentView.findViewById(android.R.id.list).setVisibility(View.GONE); mFragmentView.findViewById(R.id.fragmentLoading).setVisibility(View.GONE); View message = mFragmentView.findViewById(R.id.fragmentMessage); if (message == null) { final ViewStub messageStrub = (ViewStub) mFragmentView.findViewById(R.id.fragmentMessageStub); message = messageStrub.inflate(); } message.setVisibility(View.VISIBLE); final TextView titleView = (TextView) message.findViewById(android.R.id.title); titleView.setText(title); titleView.setCompoundDrawablesWithIntrinsicBounds(0, drawableRes, 0, 0); final TextView descriptionView = (TextView) message.findViewById(android.R.id.summary); if (description != null) { descriptionView.setText(description); descriptionView.setVisibility(View.VISIBLE); } else { descriptionView.setVisibility(View.GONE); } }
From source file:net.micode.fileexplorer.ServerControlActivity.java
/** * This will be called by the static UiUpdater whenever the service has * changed state in a way that requires us to update our UI. We can't use * any myLog.l() calls in this function, because that will trigger an * endless loop of UI updates.//w w w . j a v a 2s . c om */ public void updateUi() { myLog.l(Log.DEBUG, "Updating UI", true); WifiManager wifiMgr = (WifiManager) mActivity.getSystemService(Context.WIFI_SERVICE); int wifiState = wifiMgr.getWifiState(); WifiInfo info = wifiMgr.getConnectionInfo(); String wifiId = info != null ? info.getSSID() : null; boolean isWifiReady = FTPServerService.isWifiEnabled(); setText(R.id.wifi_state, isWifiReady ? wifiId : getString(R.string.no_wifi_hint)); ImageView wifiImg = (ImageView) mRootView.findViewById(R.id.wifi_state_image); wifiImg.setImageResource(isWifiReady ? R.drawable.wifi_state4 : R.drawable.wifi_state0); boolean running = FTPServerService.isRunning(); if (running) { myLog.l(Log.DEBUG, "updateUi: server is running", true); // Put correct text in start/stop button // Fill in wifi status and address InetAddress address = FTPServerService.getWifiIp(); if (address != null) { String port = ":" + FTPServerService.getPort(); ipText.setText( "ftp://" + address.getHostAddress() + (FTPServerService.getPort() == 21 ? "" : port)); } else { // could not get IP address, stop the service Context context = mActivity.getApplicationContext(); Intent intent = new Intent(context, FTPServerService.class); context.stopService(intent); ipText.setText(""); } } startStopButton.setEnabled(isWifiReady); TextView startStopButtonText = (TextView) mRootView.findViewById(R.id.start_stop_button_text); if (isWifiReady) { startStopButtonText.setText(running ? R.string.stop_server : R.string.start_server); startStopButtonText.setCompoundDrawablesWithIntrinsicBounds( running ? R.drawable.disconnect : R.drawable.connect, 0, 0, 0); startStopButtonText.setTextColor(running ? getResources().getColor(R.color.remote_disconnect_text) : getResources().getColor(R.color.remote_connect_text)); } else { if (FTPServerService.isRunning()) { Context context = mActivity.getApplicationContext(); Intent intent = new Intent(context, FTPServerService.class); context.stopService(intent); } startStopButtonText.setText(R.string.no_wifi); startStopButtonText.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); startStopButtonText.setTextColor(Color.GRAY); } ipText.setVisibility(running ? View.VISIBLE : View.INVISIBLE); instructionText.setVisibility(running ? View.VISIBLE : View.GONE); instructionTextPre.setVisibility(running ? View.GONE : View.VISIBLE); }
From source file:co.nerdart.ourss.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(isGroupPosition) == 1) { long feedId = cursor.getLong(idPosition); if (feedId == mSelectedFeedId) { view.setBackgroundResource(android.R.color.holo_blue_dark); } else {/*from w w w.j a va 2 s . c om*/ view.setBackgroundResource(android.R.color.transparent); } indicatorImage.setVisibility(View.VISIBLE); TextView textView = ((TextView) view.findViewById(android.R.id.text1)); textView.setEnabled(true); textView.setText(cursor.getString(namePosition)); textView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); int unreadCount; synchronized (mUnreadItemsByFeed) { unreadCount = mUnreadItemsByFeed.get(feedId); } textView.setText(cursor.getString(namePosition) + (unreadCount > 0 ? " (" + unreadCount + ")" : "")); view.findViewById(android.R.id.text2).setVisibility(View.GONE); View sortView = view.findViewById(R.id.sortitem); if (!sortViews.contains(sortView)) { // as we are reusing views, this is fine sortViews.add(sortView); } sortView.setVisibility(feedSort ? View.VISIBLE : View.GONE); final int groupPosition = cursor.getPosition(); if (!mGroupInitDone.get(groupPosition)) { mGroupInitDone.put(groupPosition, true); boolean savedExpandedState = cursor.getInt(isGroupCollapsedPosition) != 1; if (savedExpandedState && !isExpanded) { mActivity.runOnUiThread(new Runnable() { @Override public void run() { mListView.expandGroup(groupPosition); } }); } if (savedExpandedState) indicatorImage.setImageResource(R.drawable.group_expanded); else indicatorImage.setImageResource(R.drawable.group_collapsed); } else { 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:net.oschina.app.ui.MainActivity.java
private void initTabs() { MainTab[] tabs = MainTab.values();/* ww w .j a v a2s. c o m*/ final int size = tabs.length; for (int i = 0; i < size; i++) { MainTab mainTab = tabs[i]; TabSpec tab = mTabHost.newTabSpec(getString(mainTab.getResName())); View indicator = LayoutInflater.from(getApplicationContext()).inflate(R.layout.tab_indicator, null); TextView title = (TextView) indicator.findViewById(R.id.tab_title); Drawable drawable = this.getResources().getDrawable(mainTab.getResIcon()); title.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null); if (i == 2) { indicator.setVisibility(View.INVISIBLE); mTabHost.setNoTabChangedTag(getString(mainTab.getResName())); } title.setText(getString(mainTab.getResName())); tab.setIndicator(indicator); tab.setContent(new TabContentFactory() { @Override public View createTabContent(String tag) { return new View(MainActivity.this); } }); mTabHost.addTab(tab, mainTab.getClz(), null); if (mainTab.equals(MainTab.ME)) { View cn = indicator.findViewById(R.id.tab_mes); mBvNotice = new BadgeView(MainActivity.this, cn); mBvNotice.setBadgePosition(BadgeView.POSITION_TOP_RIGHT); mBvNotice.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10); mBvNotice.setBackgroundResource(R.drawable.notification_bg); mBvNotice.setGravity(Gravity.CENTER); } mTabHost.getTabWidget().getChildAt(i).setOnTouchListener(this); } }
From source file:io.github.hidroh.materialistic.ComposeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mParentId = getIntent().getStringExtra(EXTRA_PARENT_ID); if (TextUtils.isEmpty(mParentId)) { finish();/*w w w . j av a 2s. c o m*/ return; } AppUtils.setStatusBarColor(getWindow(), ContextCompat.getColor(this, R.color.blackT12)); setContentView(R.layout.activity_compose); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); //noinspection ConstantConditions getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP); mEditText = (EditText) findViewById(R.id.edittext_body); if (savedInstanceState == null) { mEditText.setText(Preferences.getDraft(this, mParentId)); } findViewById(R.id.empty).setOnClickListener(v -> mEditText.requestFocus()); findViewById(R.id.empty).setOnLongClickListener(v -> { mEditText.requestFocus(); return mEditText.performLongClick(); }); mParentText = getIntent().getStringExtra(EXTRA_PARENT_TEXT); if (!TextUtils.isEmpty(mParentText)) { findViewById(R.id.quote).setVisibility(View.VISIBLE); final TextView toggle = (TextView) findViewById(R.id.toggle); final TextView textView = (TextView) findViewById(R.id.text); AppUtils.setTextWithLinks(textView, AppUtils.fromHtml(mParentText)); toggle.setOnClickListener(v -> { if (textView.getVisibility() == View.VISIBLE) { toggle.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_expand_more_white_24dp, 0); textView.setVisibility(View.GONE); } else { toggle.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_expand_less_white_24dp, 0); textView.setVisibility(View.VISIBLE); } }); } }