Example usage for android.widget TextView setSelected

List of usage examples for android.widget TextView setSelected

Introduction

In this page you can find the example usage for android.widget TextView setSelected.

Prototype

@Override
    public void setSelected(boolean selected) 

Source Link

Usage

From source file:Main.java

public static void updateTitle(TextView view, String title) {
    if (view != null && !TextUtils.isEmpty(title)) {
        view.setVisibility(View.VISIBLE);
        view.setSelected(true);
        view.setText(title);//from   ww  w  .  j  a  v  a 2s . c  o m
    }
}

From source file:Main.java

public static void updateInfoPanel(TextView infoPanel, int color, String message) {
    if (infoPanel != null) {
        infoPanel.setTextColor(color);//w  ww.  ja  v  a2s.  c  om
        infoPanel.setText(message);
        infoPanel.setSelected(true);
        infoPanel.invalidate();
    }
}

From source file:Main.java

public static void updateStatusBar(TextView statusBarMain, int color, String message) {
    if (statusBarMain != null) {
        statusBarMain.setTextColor(color);
        statusBarMain.setText(message);/*from w w w.  ja v a 2s . c  o m*/
        statusBarMain.setSelected(true);
        statusBarMain.invalidate();
    }
}

From source file:com.hellofyc.base.util.ViewUtils.java

/**
 * ??//www.  j  a  va 2s  . com
 */
public static void setMarqueeEnabled(TextView textView) {
    textView.setSelected(true);
    textView.setSingleLine(true);
    textView.setMarqueeRepeatLimit(-1);
    textView.setEllipsize(TruncateAt.MARQUEE);
}

From source file:com.cw.litenote.note.AudioUi_note.java

public static void initAudioProgress(AppCompatActivity act, String audioUriInDB, ViewPager _pager) {
    SeekBar seekBar = (SeekBar) act.findViewById(R.id.pager_img_audio_seek_bar);
    ImageView mPager_audio_play_button = (ImageView) act.findViewById(R.id.pager_btn_audio_play);

    // set audio block listeners
    setAudioBlockListener(act, audioUriInDB, _pager);

    mProgress = 0;/*from   w  w  w .  j a v  a2 s .c o m*/

    mAudioUriInDB = audioUriInDB;
    showAudioName(act);

    TextView audioTitle = (TextView) act.findViewById(R.id.pager_audio_title);
    audioTitle.setSelected(false);
    mPager_audio_play_button.setImageResource(R.drawable.ic_media_play);
    audioTitle.setTextColor(ColorSet.getPauseColor(act));
    audioTitle.setSelected(false);

    // current position
    int curHour = Math.round((float) (mProgress / 1000 / 60 / 60));
    int curMin = Math.round((float) ((mProgress - curHour * 60 * 60 * 1000) / 1000 / 60));
    int curSec = Math.round((float) ((mProgress - curHour * 60 * 60 * 1000 - curMin * 60 * 1000) / 1000));
    String curr_pos_str = String.format(Locale.ENGLISH, "%2d", curHour) + ":"
            + String.format(Locale.ENGLISH, "%02d", curMin) + ":"
            + String.format(Locale.ENGLISH, "%02d", curSec);

    TextView audio_curr_pos = (TextView) act.findViewById(R.id.pager_audio_current_pos);
    audio_curr_pos.setText(curr_pos_str);
    audio_curr_pos.setTextColor(ColorSet.color_white);

    // audio seek bar
    seekBar.setProgress(mProgress); // This math construction give a percentage of "was playing"/"song length"
    seekBar.setMax(99); // It means 100% .0-99
    seekBar.setVisibility(View.VISIBLE);

    // get audio file length
    try {
        if (Util.isUriExisted(mAudioUriInDB, act)) {
            MediaPlayer mp = MediaPlayer.create(act, Uri.parse(mAudioUriInDB));
            mediaFileLength = mp.getDuration();
            mp.release();
        }
    } catch (Exception e) {
        System.out.println("AudioUi_note / _initAudioProgress / exception");
    }
    // set audio file length
    int fileHour = Math.round((float) (mediaFileLength / 1000 / 60 / 60));
    int fileMin = Math.round((float) ((mediaFileLength - fileHour * 60 * 60 * 1000) / 1000 / 60));
    int fileSec = Math
            .round((float) ((mediaFileLength - fileHour * 60 * 60 * 1000 - fileMin * 1000 * 60) / 1000));

    String strHour = String.format(Locale.ENGLISH, "%2d", fileHour);
    String strMinute = String.format(Locale.ENGLISH, "%02d", fileMin);
    String strSecond = String.format(Locale.ENGLISH, "%02d", fileSec);
    String strLength = strHour + ":" + strMinute + ":" + strSecond;

    TextView audio_length = (TextView) act.findViewById(R.id.pager_audio_file_length);
    audio_length.setText(strLength);
    audio_length.setTextColor(ColorSet.color_white);
}

From source file:io.github.mkjung.ivi.gui.helpers.UiTools.java

/**
 * Set the alignment mode of the specified TextView with the desired align
 * mode from preferences.// w w  w.j a  v  a 2s .  c om
 *
 * See @array/audio_title_alignment_values
 *
 * @param alignMode Align mode as read from preferences
 * @param t Reference to the textview
 */
@BindingAdapter({ "alignMode" })
public static void setAlignModeByPref(TextView t, int alignMode) {
    switch (alignMode) {
    case 0:
        break;
    case 1:
        t.setEllipsize(TextUtils.TruncateAt.END);
        break;
    case 2:
        t.setEllipsize(TextUtils.TruncateAt.START);
        break;
    case 3:
        t.setEllipsize(TextUtils.TruncateAt.MARQUEE);
        t.setMarqueeRepeatLimit(-1);
        t.setSelected(true);
        break;
    }
}

From source file:com.cw.litenote.note.AudioUi_note.java

public static void updateAudioPlayState(AppCompatActivity act) {
    ImageView audio_play_btn = (ImageView) act.findViewById(R.id.pager_btn_audio_play);

    if (Audio_manager.getAudioPlayMode() != Audio_manager.NOTE_PLAY_MODE)
        return;/*from  ww w . j ava 2s  .c o  m*/

    TextView audioTitle = (TextView) act.findViewById(R.id.pager_audio_title);
    // update playing state
    if (Audio_manager.getPlayerState() == Audio_manager.PLAYER_AT_PLAY) {
        audio_play_btn.setImageResource(R.drawable.ic_media_pause);
        showAudioName(act);
        audioTitle.setTextColor(ColorSet.getHighlightColor(act));
        audioTitle.setSelected(true);
    } else if ((Audio_manager.getPlayerState() == Audio_manager.PLAYER_AT_PAUSE)
            || (Audio_manager.getPlayerState() == Audio_manager.PLAYER_AT_STOP)) {
        audio_play_btn.setImageResource(R.drawable.ic_media_play);
        showAudioName(act);
        audioTitle.setTextColor(ColorSet.getPauseColor(act));
        audioTitle.setSelected(false);
    }
}

From source file:com.cw.litenote.note.AudioUi_note.java

static void showAudioName(AppCompatActivity act) {
    TextView audio_title_text_view = (TextView) act.findViewById(R.id.pager_audio_title);
    // title: set marquee
    if (Util.isUriExisted(mAudioUriInDB, act)) {
        String audio_name = Util.getDisplayNameByUriString(mAudioUriInDB, act);
        audio_title_text_view.setText(audio_name);
    } else/*from w  w  w .j a va2 s . c  om*/
        audio_title_text_view.setText(R.string.file_not_found);

    audio_title_text_view.setSelected(false);
}

From source file:com.example.android.tourguide.ObjectAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // Check if an existing view is being reused, otherwise inflate the view
    View listItemView = convertView;
    if (listItemView == null) {
        listItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false);
    }//  w ww .j a v a 2 s  .c  om

    // Get the {@link Object} object located at this position in the list
    final Object currentObject = getItem(position);

    // Find the TextView in the list_item.xml layout with the ID name_text_view.
    TextView objectNameTV = (TextView) listItemView.findViewById(R.id.name_text_view);
    objectNameTV.setSelected(true);
    objectNameTV.setText(currentObject.getObjectName());

    // Find the TextView in the list_item.xml layout with the ID address_text_view.
    TextView addressTV = (TextView) listItemView.findViewById(R.id.address_text_view);
    addressTV.setSelected(true);
    addressTV.setText(currentObject.getObjectAddress());

    // Find the TextView in the list_item.xml layout with the ID description_text_view.
    TextView objectDescription = (TextView) listItemView.findViewById(R.id.description_text_view);
    objectDescription.setText(currentObject.getObjectDescription());

    // Find the ImageView in the list_item.xml layout with the ID image.
    final ImageView imageView = (ImageView) listItemView.findViewById(R.id.image);
    // Check if an image is provided for this word or not
    if (currentObject.hasImage()) {
        // If an image is available, display the provided image based on the resource ID
        imageView.setImageResource(currentObject.getImageResourceId());
        // Make sure the view is visible
        imageView.setVisibility(View.VISIBLE);
    } else {
        // Otherwise hide the ImageView (set visibility to GONE)
        imageView.setVisibility(View.GONE);
    }

    LinearLayout textContainer = (LinearLayout) listItemView.findViewById(R.id.text_container);
    int color = ContextCompat.getColor(getContext(), mColorResourceId);
    textContainer.setBackgroundColor(color);

    textContainer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (currentObject.hasImage()) {
                if (imageView.getVisibility() == View.GONE) {
                    imageView.setVisibility(View.VISIBLE);
                } else {
                    imageView.setVisibility(View.GONE);
                }
            }
        }
    });

    // Return the whole list item layout (containing 2 TextViews) so that it can be shown in
    // the ListView.
    return listItemView;
}

From source file:net.peterkuterna.android.apps.devoxxfrsched.ui.widget.ScrollableTabs.java

public void focusTab(int index) {
    final int tabCount = mHost.getChildCount();

    if (index < 0 || index > tabCount - 1) {
        return;/*from w  w  w .jav a 2  s . c o m*/
    }

    if (mCurrentTab != index) {
        final TextView tvOld = (TextView) mHost.getChildAt(mCurrentTab);
        if (tvOld != null) {
            tvOld.setSelected(false);
        }

        mCurrentTab = index;

        final TextView tvNew = (TextView) mHost.getChildAt(index);
        if (tvNew != null) {
            int right = tvNew.getRight();
            int left = tvNew.getLeft() + right;
            int width = getWidth();
            int i = (left - width) / 2;
            tvNew.setSelected(true);
            smoothScrollTo(i, 0);
        }
    }
}