Example usage for android.widget TextView setMarqueeRepeatLimit

List of usage examples for android.widget TextView setMarqueeRepeatLimit

Introduction

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

Prototype

public void setMarqueeRepeatLimit(int marqueeLimit) 

Source Link

Document

Sets how many times to repeat the marquee animation.

Usage

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

/**
 * ??//from w ww.  j  a  v a2  s  .  c  o  m
 */
public static void setMarqueeEnabled(TextView textView) {
    textView.setSelected(true);
    textView.setSingleLine(true);
    textView.setMarqueeRepeatLimit(-1);
    textView.setEllipsize(TruncateAt.MARQUEE);
}

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.// www.  java  2s  .  co m
 *
 * 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.mods.grx.settings.utils.Utils.java

public static void animate_textview_marquee(TextView textView) {
    textView.setTextIsSelectable(true);/*from   w  ww . ja va  2s  .  c o m*/
    textView.setSingleLine(true);
    textView.setHorizontallyScrolling(true);
    textView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
    textView.setMarqueeRepeatLimit(1);
}

From source file:net.lp.actionbarpoirot.helpers.ActivityHelperHoneycomb.java

/** {@inheritDoc} */
@Override//from w ww . j a  v  a 2  s.  co m
public void enableActionBarTitleMarquee() {
    // Make title scrolling, a bit of a hack
    final TextView titleView = (TextView) mActivity.findViewById(actionBarTitleResId);
    if (titleView != null) {
        titleView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
        titleView.setMarqueeRepeatLimit(-1);
        titleView.setFocusable(true);
        titleView.setFocusableInTouchMode(true);
        titleView.requestFocus();// TODO: action bar title doesn't keep
        // scrolling after you've touched
        // something else. Should fix that.
    }

    // Also focus LeftNavBar, a bit of a hack too
    final View view = (mActivity.findViewById(leftNavActionBarResId));
    if (view != null) {
        view.setFocusable(true);
        view.setFocusableInTouchMode(true);
        view.requestFocus();
    }
}

From source file:com.rukiasoft.androidapps.cocinaconroll.ui.ToolbarAndRefreshActivity.java

public void setToolbar(Toolbar toolbar) {
    setSupportActionBar(toolbar);/* w w  w  . j a  va 2  s . co m*/
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    try {
        if (toolbar.getClass() != null) {
            Field f = toolbar.getClass().getDeclaredField("mTitleTextView");
            f.setAccessible(true);
            TextView titleTextView = (TextView) f.get(toolbar);
            titleTextView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
            titleTextView.setFocusable(true);
            titleTextView.setFocusableInTouchMode(true);
            titleTextView.requestFocus();
            titleTextView.setSingleLine(true);
            titleTextView.setSelected(true);
            titleTextView.setMarqueeRepeatLimit(-1);
        }
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.example.samsungmdm.MainActivity.java

public void onServerResponse(String response) {
    TextView serverResponseTextView = new TextView(this);
    serverResponseTextView.setHorizontallyScrolling(true);
    serverResponseTextView.setSingleLine();
    serverResponseTextView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
    serverResponseTextView.setFocusableInTouchMode(true);
    serverResponseTextView.setMarqueeRepeatLimit(1);
    serverResponseTextView.setFocusable(true);
    String myTime = java.text.DateFormat.getTimeInstance().format(Calendar.getInstance().getTime());
    serverResponseTextView.setText(myTime + " - " + response);

    mServerResponseLinearLayout.addView(serverResponseTextView, 0);

    //Parsing server response
    try {// w w  w. j  ava 2s. c  om
        parseServerResponse(new JSONObject(response));
    } catch (JSONException e) {
        Log.e(TAG, "Invalid JSON response from the server");
        e.printStackTrace();
    }
}

From source file:org.mozilla.gecko.overlays.ui.ShareDialog.java

@Override
protected void onResume() {
    super.onResume();

    final Intent intent = getIntent();

    state = intent.getBooleanExtra(INTENT_EXTRA_DEVICES_ONLY, false) ? State.DEVICES_ONLY : State.DEFAULT;

    // If the Activity is being reused, we need to reset the state. Ideally, we create a
    // new instance for each call, but Android L breaks this (bug 1137928).
    sendTabList.switchState(SendTabList.State.LOADING);
    readingListButton.setBackgroundDrawable(readingListButtonDrawable);

    // The URL is usually hiding somewhere in the extra text. Extract it.
    final String extraText = ContextUtils.getStringExtra(intent, Intent.EXTRA_TEXT);
    if (TextUtils.isEmpty(extraText)) {
        abortDueToNoURL();/*from   w  w w  .  j av a2  s  . co  m*/
        return;
    }

    final String pageUrl = new WebURLFinder(extraText).bestWebURL();
    if (TextUtils.isEmpty(pageUrl)) {
        abortDueToNoURL();
        return;
    }

    // Have the service start any initialisation work that's necessary for us to show the correct
    // UI. The results of such work will come in via the BroadcastListener.
    Intent serviceStartupIntent = new Intent(this, OverlayActionService.class);
    serviceStartupIntent.setAction(OverlayConstants.ACTION_PREPARE_SHARE);
    startService(serviceStartupIntent);

    // Start the slide-up animation.
    getWindow().setWindowAnimations(0);
    final Animation anim = AnimationUtils.loadAnimation(this, R.anim.overlay_slide_up);
    findViewById(R.id.sharedialog).startAnimation(anim);

    // If provided, we use the subject text to give us something nice to display.
    // If not, we wing it with the URL.

    // TODO: Consider polling Fennec databases to find better information to display.
    final String subjectText = intent.getStringExtra(Intent.EXTRA_SUBJECT);

    final String telemetryExtras = "title=" + (subjectText != null);
    if (subjectText != null) {
        ((TextView) findViewById(R.id.title)).setText(subjectText);
    }

    Telemetry.sendUIEvent(TelemetryContract.Event.SHOW, TelemetryContract.Method.SHARE_OVERLAY,
            telemetryExtras);

    title = subjectText;
    url = pageUrl;

    // Set the subtitle text on the view and cause it to marquee if it's too long (which it will
    // be, since it's a URL).
    final TextView subtitleView = (TextView) findViewById(R.id.subtitle);
    subtitleView.setText(pageUrl);
    subtitleView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
    subtitleView.setSingleLine(true);
    subtitleView.setMarqueeRepeatLimit(5);
    subtitleView.setSelected(true);

    final View titleView = findViewById(R.id.title);

    if (state == State.DEVICES_ONLY) {
        bookmarkButton.setVisibility(View.GONE);
        readingListButton.setVisibility(View.GONE);

        titleView.setOnClickListener(null);
        subtitleView.setOnClickListener(null);
        return;
    }

    bookmarkButton.setVisibility(View.VISIBLE);
    readingListButton.setVisibility(View.VISIBLE);

    // Configure buttons.
    final View.OnClickListener launchBrowser = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ShareDialog.this.launchBrowser();
        }
    };

    titleView.setOnClickListener(launchBrowser);
    subtitleView.setOnClickListener(launchBrowser);

    final LocalBrowserDB browserDB = new LocalBrowserDB(getCurrentProfile());
    setButtonState(url, browserDB);
}

From source file:busradar.madison.StopDialog.java

StopDialog(final Context ctx, final int stopid, final int lat, final int lon) {
    super(ctx);/*from  w ww  .  j a v a2 s  . c o m*/
    this.stopid = stopid;

    // getWindow().requestFeature(Window.FEATURE_LEFT_ICON);
    getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);

    final String name = DB.getStopName(stopid);
    setTitle(name);

    routes = get_time_urls(StopDialog.this.stopid);

    // getWindow().setLayout(LayoutParams.FILL_PARENT,
    // LayoutParams.FILL_PARENT);

    setContentView(new RelativeLayout(ctx) {
        {
            addView(new TextView(ctx) {
                {
                    setId(stop_num_id);
                    setText(Html.fromHtml(String.format(
                            "[<a href='http://www.cityofmadison.com/metro/BusStopDepartures/StopID/%04d.pdf'>%04d</a>]",
                            stopid, stopid)));
                    setPadding(0, 0, 5, 0);
                    this.setMovementMethod(LinkMovementMethod.getInstance());
                }
            }, new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) {
                {
                    addRule(ALIGN_PARENT_RIGHT);
                }
            });

            addView(new ImageView(ctx) {
                boolean enabled;

                @Override
                public void setEnabled(boolean e) {
                    enabled = e;

                    setImageResource(e ? R.drawable.love_enabled : R.drawable.love_disabled);
                    if (e) {
                        G.favorites.add_favorite_stop(stopid, name, lat, lon);
                        Toast.makeText(ctx, "Added stop to Favorites", Toast.LENGTH_SHORT).show();
                    } else {
                        G.favorites.remove_favorite_stop(stopid);
                        Toast.makeText(ctx, "Removed stop from Favorites", Toast.LENGTH_SHORT).show();
                    }
                }

                {
                    enabled = G.favorites.is_stop_favorite(stopid);
                    setImageResource(enabled ? R.drawable.love_enabled : R.drawable.love_disabled);

                    setPadding(0, 0, 10, 0);
                    setOnClickListener(new OnClickListener() {
                        public void onClick(View v) {
                            setEnabled(!enabled);
                        }
                    });
                }
            }, new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) {
                {
                    addRule(LEFT_OF, stop_num_id);
                    setMargins(0, -3, 0, 0);
                }
            });

            addView(cur_loading_text = new TextView(ctx) {
                {
                    setText("Loading...");
                    setPadding(5, 0, 0, 0);
                }
            });
            addView(new HorizontalScrollView(ctx) {
                {
                    setId(route_list_id);
                    setHorizontalScrollBarEnabled(false);

                    addView(new LinearLayout(ctx) {
                        float text_size;
                        Button cur_button;
                        {
                            int last_route = -1;
                            for (int i = 0; i < routes.length; i++) {

                                final RouteURL route = routes[i];

                                if (route.route == last_route)
                                    continue;
                                last_route = route.route;

                                addView(new Button(ctx) {
                                    public void setEnabled(boolean e) {
                                        if (e) {
                                            setBackgroundColor(0xff000000 | G.route_points[route.route].color);
                                            setTextSize(TypedValue.COMPLEX_UNIT_PX, text_size * 1.5f);
                                        } else {
                                            setBackgroundColor(0x90000000 | G.route_points[route.route].color);
                                            setTextSize(TypedValue.COMPLEX_UNIT_PX, text_size);
                                        }
                                    }

                                    {
                                        setText(G.route_points[route.route].name);
                                        setTextColor(0xffffffff);
                                        setTypeface(Typeface.DEFAULT_BOLD);
                                        text_size = getTextSize();

                                        if (G.active_route == route.route) {
                                            setEnabled(true);
                                            cur_button = this;
                                        } else
                                            setEnabled(false);

                                        final Button b = this;

                                        setOnClickListener(new OnClickListener() {
                                            public void onClick(View v) {
                                                if (cur_button != null) {
                                                    cur_button.setEnabled(false);
                                                }

                                                if (cur_button == b) {
                                                    cur_button.setEnabled(false);
                                                    cur_button = null;

                                                    selected_route = null;
                                                    update_time_display();
                                                } else {
                                                    cur_button = b;
                                                    cur_button.setEnabled(true);

                                                    selected_route = route;
                                                    update_time_display();
                                                }
                                            }
                                        });

                                    }
                                });
                            }
                        }
                    });
                }
            }, new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) {
                {
                    addRule(RelativeLayout.BELOW, stop_num_id);
                    addRule(RelativeLayout.CENTER_HORIZONTAL);
                }
            });

            addView(status_text = new TextView(ctx) {
                {
                    setText("");
                }
            }, new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) {
                {
                    addRule(RelativeLayout.BELOW, route_list_id);
                    addRule(RelativeLayout.CENTER_HORIZONTAL);
                }
            });
            addView(list_view = new ListView(ctx) {
                {
                    setId(time_list_id);
                    setVerticalScrollBarEnabled(false);
                    setAdapter(times_adapter = new BaseAdapter() {

                        public View getView(final int position, View convertView, ViewGroup parent) {
                            CellView v;

                            if (convertView == null)
                                v = new CellView(ctx);
                            else
                                v = (CellView) convertView;

                            RouteTime rt = curr_times.get(position);
                            v.setBackgroundColor(G.route_points[rt.route].color | 0xff000000);
                            v.route_textview.setText(G.route_points[rt.route].name);
                            if (rt.dir != null)
                                v.dir_textview.setText("to " + rt.dir);
                            v.time_textview.setText(rt.time);

                            return v;

                        }

                        public int getCount() {
                            return curr_times.size();
                        }

                        public Object getItem(int position) {
                            return null;
                        }

                        public long getItemId(int position) {
                            return 0;
                        }

                    });
                }
            }, new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT) {
                {
                    addRule(RelativeLayout.BELOW, route_list_id);
                }
            });
        }
    });

    TextView title = (TextView) findViewById(android.R.id.title);
    title.setEllipsize(TextUtils.TruncateAt.MARQUEE);
    title.setSelected(true);
    title.setTextColor(0xffffffff);
    title.setMarqueeRepeatLimit(-1);

    // getWindow().set, value)
    // getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
    // android.R.drawable.ic_dialog_info);

    // title.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL);

    if (G.active_route >= 0)
        for (int i = 0; i < routes.length; i++)
            if (routes[i].route == G.active_route) {
                selected_route = routes[i];

                RouteURL[] rnew = new RouteURL[routes.length];
                rnew[0] = selected_route;

                for (int j = 0, k = 1; j < routes.length; j++)
                    if (j != i)
                        rnew[k++] = routes[j];

                routes = rnew;
                break;
            }
    update_time_display();
}