Example usage for android.widget TextView setMovementMethod

List of usage examples for android.widget TextView setMovementMethod

Introduction

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

Prototype

public final void setMovementMethod(MovementMethod movement) 

Source Link

Document

Sets the android.text.method.MovementMethod for handling arrow key movement for this TextView.

Usage

From source file:org.liberty.android.fantastischmemo.ui.AnyMemo.java

private void prepareFirstTimeRun() {
    File sdPath = new File(AMEnv.DEFAULT_ROOT_PATH);
    //Check the version, if it is updated from an older version it will show a dialog
    int savedVersionCode = settings.getInt(AMPrefKeys.SAVED_VERSION_CODE_KEY, 1);

    int thisVersionCode;
    try {//from w ww. j  a v  a 2  s .c om
        thisVersionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
    } catch (PackageManager.NameNotFoundException e) {
        thisVersionCode = 0;
        assert false : "The version code can not be retrieved. Is it defined in build.gradle?";
    }

    boolean firstTime = settings.getBoolean(AMPrefKeys.FIRST_TIME_KEY, true);

    // Force clean preference for non-compstible versions.
    if (savedVersionCode < 154) { // Version 9.0.4
        firstTime = true;
        SharedPreferences.Editor editor = settings.edit();
        editor.clear();
        editor.commit();
    }

    /* First time installation! It will install the sample db
     * to /sdcard/AnyMemo
     */
    if (firstTime == true) {
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(AMPrefKeys.FIRST_TIME_KEY, false);
        editor.putString(AMPrefKeys.getRecentPathKey(0), AMEnv.DEFAULT_ROOT_PATH + AMEnv.DEFAULT_DB_NAME);
        editor.commit();
        try {
            amFileUtil.copyFileFromAsset(AMEnv.DEFAULT_DB_NAME, new File(sdPath + "/" + AMEnv.DEFAULT_DB_NAME));

            InputStream in2 = getResources().getAssets().open(AMEnv.EMPTY_DB_NAME);
            String emptyDbPath = getApplicationContext().getFilesDir().getAbsolutePath() + "/"
                    + AMEnv.EMPTY_DB_NAME;
            FileUtils.copyInputStreamToFile(in2, new File(emptyDbPath));
            in2.close();
        } catch (IOException e) {
            Log.e(TAG, "Copy file error", e);

        }
    }
    /* Detect an update */
    if (savedVersionCode != thisVersionCode) {
        SharedPreferences.Editor editor = settings.edit();
        /* save new version number */
        editor.putInt(AMPrefKeys.SAVED_VERSION_CODE_KEY, thisVersionCode);
        editor.commit();

        View alertView = View.inflate(this, R.layout.link_alert, null);
        TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message);
        textView.setText(Html.fromHtml(getString(R.string.what_is_new_message)));
        textView.setMovementMethod(LinkMovementMethod.getInstance());
        new AlertDialog.Builder(this).setView(alertView).setTitle(getString(R.string.what_is_new))
                .setPositiveButton(getString(R.string.ok_text), null)
                .setNegativeButton(getString(R.string.about_version), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        Intent myIntent = new Intent();
                        myIntent.setAction(Intent.ACTION_VIEW);
                        myIntent.addCategory(Intent.CATEGORY_BROWSABLE);
                        myIntent.setData(Uri.parse(WEBSITE_VERSION));
                        startActivity(myIntent);
                    }
                }).show();
    }
}

From source file:com.dodo.wbbshoutbox.codebot.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    context = getApplicationContext();/*from   w w  w. jav  a  2  s .  co m*/

    checkUpdate();

    Request.client.setUserAgent("Dodo Shoutboxapp");

    myCookieStore = new PersistentCookieStore(this);
    Request.client.setCookieStore(myCookieStore);

    Usernamefield = (TextView) findViewById(R.id.txtUsername);
    Sendbutton = (Button) findViewById(R.id.cmdSend);
    Refreshbutton = (Button) findViewById(R.id.cmdRefresh);
    pbReadChat = (ProgressBar) findViewById(R.id.pbReadChat);
    lblVerlauf = (TextView) findViewById(R.id.lblVerlauf);
    lblAutoRefresh = (TextView) findViewById(R.id.lblAutorefresh);

    if (UserData.readPref("textsize", this).equals("")) {
        UserData.writePref("textsize", "10", this);
    }
    if (UserData.readPref("refreshcircle", this).equals("")) {
        UserData.writePref("refreshcircle", "1", this);
        refreshanimation = 1;
    } else if (UserData.readPref("refreshcircle", this).equals("1")) {
        refreshanimation = 1;
    }
    /*
     * if(UserData.readPref("changechatdirection", this).equals("")) {
     * UserData.writePref("changechatdirection", "0", this); } else
     * if(UserData.readPref("changechatdirection", this).equals("1")) {
     * changechatdirection = 1; }
     */
    if (UserData.readPref("showtime", this).equals("")) {
        UserData.writePref("showtime", "1", this);
    } else {
        showTime = Integer.valueOf(UserData.readPref("showtime", this));
    }

    if (!UserData.readPref("username", this).equals("")) {
        Usernamefield.setText(UserData.readPref("username", this));
    }

    if (!UserData.readPref("autorefresh", this).equals("")) {
        Button cmdRefresh = (Button) findViewById(R.id.cmdRefresh);
        TextView lblARefresh = (TextView) findViewById(R.id.lblAutorefresh);

        cmdRefresh.setVisibility(Button.INVISIBLE);
        lblARefresh.setVisibility(TextView.VISIBLE);
        Toast.makeText(this, "Automatisches Laden aktiviert!", Toast.LENGTH_SHORT).show();
        autorefresh = 1;
    }

    if (UserData.readPref("ar_intervall", this).equals("")) {
        UserData.writePref("ar_intervall", "30000", this);
    }

    setTextSize();
    setCookies();

    final Button cmdSend = (Button) findViewById(R.id.cmdSend);
    if (requireLogin == 1 && loggedIn == 0) {
        cmdSend.setEnabled(false);
        cmdSend.setText("Zuerst einloggen!");
    }
    cmdSend.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            InputMethodManager inputManager = (InputMethodManager) getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);

            send();
        }
    });

    final Button cmdRefresh = (Button) findViewById(R.id.cmdRefresh);
    cmdRefresh.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            getRequest(baseUrl + "index.php?page=ShoutboxEntryXMLList");
        }
    });

    final Button cmdMenu = (Button) findViewById(R.id.cmdMenu);
    cmdMenu.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            InputMethodManager inputManager = (InputMethodManager) getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);

            // openOptionsMenu();
            Intent myIntent2 = new Intent(getApplicationContext(), Settings2.class);
            startActivityForResult(myIntent2, 0);
        }
    });

    TextView lblVerlauf = (TextView) findViewById(R.id.lblVerlauf);
    lblVerlauf.setMovementMethod(LinkMovementMethod.getInstance());
    lblVerlauf.setMovementMethod(new ScrollingMovementMethod());

}

From source file:app.hacked.ScheduleItemDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.schedule_detail_fragment, container, false);

    ((TextView) rootView.findViewById(R.id.times)).setText(scheduleStartTime + " till " + scheduleEndTime);
    ((TextView) rootView.findViewById(R.id.times))
            .setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));

    if (rootView.findViewById(R.id.Title) != null) {
        ((TextView) rootView.findViewById(R.id.Title)).setText(scheduleDesc);
        ((TextView) rootView.findViewById(R.id.Title))
                .setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));
        ((TextView) rootView.findViewById(R.id.times))
                .setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));
        getActivity().getActionBar()//from w ww  . ja  v a 2s. com
                .setTitle(scheduleTitle + " - " + getActivity().getString(R.string.app_name));
    }

    TextView fullDetailsTV = (TextView) rootView.findViewById(R.id.fullDetails);

    if (null == scheduleFullDataHTML || scheduleFullDataHTML.equals("")
            || scheduleFullDataHTML.equals("null")) {
        fullDetailsTV.setText(Html.fromHtml(scheduleDesc));
    } else {
        fullDetailsTV.setText(Html.fromHtml(scheduleFullDataHTML));
    }
    fullDetailsTV.setTypeface(Typeface.create("sans-serif", Typeface.NORMAL));

    try {
        fullDetailsTV.setMovementMethod(LinkMovementMethod.getInstance());
    } catch (Exception e) {
        //Worth a shot
    }
    return rootView;
}

From source file:com.limewoodmedia.nsdroid.fragments.OfficersFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    root = inflater.inflate(R.layout.officers, null, false);
    list = (ListView) root.findViewById(R.id.officers_list);

    officers = new ArrayList<Officer>();
    officersComparator = new OfficersComparator();
    listAdapter = new ArrayAdapter<Officer>(context, 0, officers) {
        @Override/* www .  j  av a  2  s .  c o  m*/
        public View getView(int position, View convertView, ViewGroup parent) {
            View view;
            TextView name, office, authority;
            Officer officer;

            if (convertView == null) {
                view = inflater.inflate(R.layout.officer, null);
            } else {
                view = convertView;
            }
            name = (TextView) view.findViewById(R.id.officer_name);
            name.setMovementMethod(LinkMovementMethod.getInstance());
            office = (TextView) view.findViewById(R.id.officer_office);
            authority = (TextView) view.findViewById(R.id.officer_authority);
            officer = getItem(position);

            // Name
            String oName = TagParser.idToName(officer.nation);
            name.setText(Html.fromHtml(oName));
            // Office
            office.setText(officer.office);
            // Authority
            StringBuilder sb = new StringBuilder();
            int i = 0;
            for (Officer.Authority auth : officer.authority) {
                sb.append(auth.name);
                if (i + 1 < officer.authority.size()) {
                    sb.append(", ");
                }
                i++;
            }
            authority.setText(sb.toString());

            view.setTag(officer);
            view.setOnClickListener(OfficersFragment.this);
            name.setOnClickListener(OfficersFragment.this);
            office.setOnClickListener(OfficersFragment.this);

            return view;
        }
    };
    list.setAdapter(listAdapter);

    return root;
}

From source file:com.cerema.cloud2.ui.activity.ErrorsWhileCopyingHandlerActivity.java

/**
 * {@link}/*from  w w  w  .j  a  v a2 s.  c om*/
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /// read extra parameters in intent
    Intent intent = getIntent();
    mAccount = intent.getParcelableExtra(EXTRA_ACCOUNT);
    mRemotePaths = intent.getStringArrayListExtra(EXTRA_REMOTE_PATHS);
    mLocalPaths = intent.getStringArrayListExtra(EXTRA_LOCAL_PATHS);
    mStorageManager = new FileDataStorageManager(mAccount, getContentResolver());
    mHandler = new Handler();
    if (mCurrentDialog != null) {
        mCurrentDialog.dismiss();
        mCurrentDialog = null;
    }

    /// load generic layout
    setContentView(R.layout.generic_explanation);

    /// customize text message
    TextView textView = (TextView) findViewById(R.id.message);
    String appName = getString(R.string.app_name);
    String message = String.format(getString(R.string.sync_foreign_files_forgotten_explanation), appName,
            appName, appName, appName, mAccount.name);
    textView.setText(message);
    textView.setMovementMethod(new ScrollingMovementMethod());

    /// load the list of local and remote files that failed
    ListView listView = (ListView) findViewById(R.id.list);
    if (mLocalPaths != null && mLocalPaths.size() > 0) {
        mAdapter = new ErrorsWhileCopyingListAdapter();
        listView.setAdapter(mAdapter);
    } else {
        listView.setVisibility(View.GONE);
        mAdapter = null;
    }

    /// customize buttons
    Button cancelBtn = (Button) findViewById(R.id.cancel);
    Button okBtn = (Button) findViewById(R.id.ok);

    okBtn.setText(R.string.foreign_files_move);
    cancelBtn.setOnClickListener(this);
    okBtn.setOnClickListener(this);
}

From source file:com.jwork.dhammapada.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    log.v(this, "onCreate()");
    if (CrashHandler.getInstance().isCrashFlag()) {
        log.v(this, "Crash flag detected");
        showCrashDialog();/*from w  w w. ja v a2s . c  o  m*/
    } else {
        //         setTheme(MainActivity.THEME);
        //         requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
        mainLayout = (FrameLayout) findViewById(R.id.mainLayout);
        mainLayout.getForeground().setAlpha(0);

        LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        aboutWindow = new PopupWindow(inflater.inflate(R.layout.activity_about, null, false),
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true);
        TextView text = ((TextView) aboutWindow.getContentView().findViewById(R.id.about_text));
        text.setText(Html.fromHtml(
                getString(R.string.about_html).replaceAll("\\{0\\}", CrashHandler.getVersionName(this))
                        .replaceAll("\\{1\\}", "" + CrashHandler.getVersionCode(this))));
        text.setMovementMethod(LinkMovementMethod.getInstance());
        ImageButton button = ((ImageButton) aboutWindow.getContentView().findViewById(R.id.about_ok));
        button.setOnClickListener(this);

        controller = new DhammapadaController(this, viewHandler);

        Message message = Message.obtain();
        message.what = Constant.WHAT_DISPLAY_CHAPTER;
        controller.executeMessage(message);

        message = Message.obtain();
        message.what = Constant.WHAT_INIT;
        controller.executeMessage(message);

        //         ActionBar actionBar = getSupportActionBar();
        //         actionBar.hide();
        //         actionBar.setTitle("Dhammapada");
        //         actionBar.setSubtitle("Chapter");
        //         actionBar.setLogo(R.drawable.ic_launcher);
        //         actionBar.show();
    }
}

From source file:me.futuretechnology.blops.ui.NewsInfoActivity.java

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

    Intent intent = getIntent();// ww  w  .  j  a  v  a  2  s . c om

    StringBuilder txtCaption = new StringBuilder(128);
    String author = intent.getStringExtra(EXTRA_AUTHOR);
    if (!TextUtils.isEmpty(author)) {
        txtCaption.append(author);
        txtCaption.append('\n');
    }
    txtCaption.append(DateTime.formatDateTime(this, intent.getLongExtra(EXTRA_DATE, 0), ", "));

    TextView tvDate = (TextView) findViewById(R.id.news_caption);
    tvDate.setText(txtCaption);

    TextView tvTitle = (TextView) findViewById(R.id.news_title);
    tvTitle.setText(intent.getStringExtra(EXTRA_TITLE));

    TextView tvContent = (TextView) findViewById(R.id.news_content);

    String txt = intent.getStringExtra(EXTRA_CONTENT_VALUES);
    tvContent.setText(Html.fromHtml(txt, null, new HtmlTagHandler()));

    // tvContent.setText(Html.fromHtml("Hello  <b>world</b>!<br>This is only a <a href=\"http://www.google.com\">test</a>."));
    tvContent.setMovementMethod(LinkMovementMethod.getInstance());

    // Log.i("BLOPS", "types: ", intent.getStringExtra(EXTRA_CONTENT_TYPES));
    Log.i("BLOPS", "values: ", txt);
    // Log.i("BLOPS", "url: ", intent.getStringExtra(EXTRA_URL));
    // Log.i("BLOPS", "id: ", intent.getStringExtra(EXTRA_ID));

    final String url = getIntent().getStringExtra(EXTRA_URL);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_open_in_browser);

    if (TextUtils.isEmpty(url)) {
        fab.setVisibility(View.GONE);
    } else {
        fab.setVisibility(View.VISIBLE);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent iBrowser = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                iBrowser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(iBrowser);
            }
        });
        fab.attachToScrollView((ObservableScrollView) findViewById(R.id.news_container));
    }
}

From source file:ro.edi.novelty.ui.NewsInfoActivity.java

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

    Intent intent = getIntent();//from  ww w.  j  a  v a  2s .  co m

    StringBuilder txtCaption = new StringBuilder(128);
    String author = intent.getStringExtra(EXTRA_AUTHOR);
    if (!TextUtils.isEmpty(author)) {
        txtCaption.append(author);
        txtCaption.append('\n');
    }
    txtCaption.append(DateTime.formatDateTime(this, intent.getLongExtra(EXTRA_DATE, 0), ", "));

    TextView tvDate = (TextView) findViewById(R.id.news_caption);
    tvDate.setText(txtCaption);

    TextView tvTitle = (TextView) findViewById(R.id.news_title);
    tvTitle.setText(intent.getStringExtra(EXTRA_TITLE));

    TextView tvContent = (TextView) findViewById(R.id.news_content);

    String txt = intent.getStringExtra(EXTRA_CONTENT_VALUES);
    tvContent.setText(Html.fromHtml(txt, null, new HtmlTagHandler()));

    // tvContent.setText(Html.fromHtml("Hello  <b>world</b>!<br>This is only a <a href=\"http://www.google.com\">test</a>."));
    tvContent.setMovementMethod(LinkMovementMethod.getInstance());

    // Log.i("NOVELTY", "types: ", intent.getStringExtra(EXTRA_CONTENT_TYPES));
    Log.i("NOVELTY", "values: ", txt);
    // Log.i("NOVELTY", "url: ", intent.getStringExtra(EXTRA_URL));
    // Log.i("NOVELTY", "id: ", intent.getStringExtra(EXTRA_ID));

    final String url = getIntent().getStringExtra(EXTRA_URL);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_open_in_browser);

    if (TextUtils.isEmpty(url)) {
        fab.setVisibility(View.GONE);
    } else {
        fab.setVisibility(View.VISIBLE);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent iBrowser = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                iBrowser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(iBrowser);
            }
        });
        fab.attachToScrollView((ObservableScrollView) findViewById(R.id.news_container));
    }
}

From source file:co.dilaver.quoter.fragments.AboutMeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_about_me, container, false);

    TextView mail = (TextView) view.findViewById(R.id.tvEmail);
    TextView twitter = (TextView) view.findViewById(R.id.tvTwitter);
    TextView facebook = (TextView) view.findViewById(R.id.tvFacebook);
    TextView linkedIn = (TextView) view.findViewById(R.id.tvLinkedIn);

    mail.setOnClickListener(new View.OnClickListener() {
        @Override//ww w.ja va 2s . c o  m
        public void onClick(View v) {
            Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
            emailIntent.setData(Uri.parse("mailto: mdilaveroglu@gmail.com"));
            startActivity(emailIntent);
        }
    });
    twitter.setMovementMethod(LinkMovementMethod.getInstance());
    facebook.setMovementMethod(LinkMovementMethod.getInstance());
    linkedIn.setMovementMethod(LinkMovementMethod.getInstance());

    return view;
}

From source file:de.tap.easy_xkcd.Activities.AboutActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    PrefHelper prefHelper = new PrefHelper(getApplicationContext());
    setTheme(prefHelper.getTheme());//from w  w  w  .  j a  v  a2  s.c  o m
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);

    android.support.v7.widget.Toolbar toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    assert getSupportActionBar() != null;
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    TypedValue typedValue = new TypedValue();
    getTheme().resolveAttribute(R.attr.colorPrimaryDark, typedValue, true);
    TypedValue typedValue2 = new TypedValue();
    getTheme().resolveAttribute(R.attr.colorPrimary, typedValue2, true);
    toolbar.setBackgroundColor(typedValue2.data);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().setStatusBarColor(typedValue.data);
        if (!prefHelper.colorNavbar())
            getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.ColorPrimaryBlack));
    }
    TextView tvAbout = (TextView) findViewById(R.id.tvAbout);
    InputStream is = getResources().openRawResource(R.raw.licenses);
    BufferedReader br = new BufferedReader(new InputStreamReader(is));
    StringBuilder sb = new StringBuilder();
    String line;
    try {
        while ((line = br.readLine()) != null) {
            sb.append(line);
        }
    } catch (IOException e) {
        Log.e("error:", e.getMessage());
    }
    tvAbout.setText(Html.fromHtml(sb.toString()));
    tvAbout.setMovementMethod(LinkMovementMethod.getInstance());
}