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.downloader.AbstractDownloaderFragment.java

protected void showFetchDatabaseDialog(final DownloadItem item) {
    View alertView = View.inflate(mActivity, R.layout.link_alert, null);
    TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setText(/*  w  w w. j  a va2s.c  om*/
            Html.fromHtml(getString(R.string.downloader_download_alert_message) + item.getDescription()));
    new AlertDialog.Builder(mActivity).setView(alertView)
            .setTitle(getString(R.string.downloader_download_alert) + item.getTitle())
            .setPositiveButton(getString(R.string.yes_text), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface arg0, int arg1) {
                    startFetchDatabaseTask(item);
                }
            }).setNegativeButton(getString(R.string.no_text), null).show();
}

From source file:com.grokkingandroid.sampleapp.samples.SampleBaseFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_demo_base, container, false);
    if (isFragmentWithInlineDescription()) {
        TextView description = (TextView) rootView.findViewById(R.id.demoapp_fragment_description);
        Spanned descSpannable = Html.fromHtml(getResources().getString(getDescriptionTextId()));
        description.setText(descSpannable);
        description.setMovementMethod(LinkMovementMethod.getInstance());
        ViewGroup linkContainer = (ViewGroup) rootView.findViewById(R.id.container_demo_blog_links);
        showLinks(linkContainer);//from www  . j a  v a 2s  .  c  o  m
        linkContainer.invalidate();
    } else {
        rootView.findViewById(R.id.container_demo_description).setVisibility(View.GONE);
        rootView.findViewById(R.id.container_demo_blog_links).setVisibility(View.GONE);
    }

    // delegate to subclass for content view
    ViewGroup contentContainer = (ViewGroup) rootView.findViewById(R.id.container_demo_content);
    onCreateContentView(inflater, contentContainer, savedInstanceState);
    return rootView;
}

From source file:org.ciasaboark.tacere.activity.AboutActivity.java

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

    ongoingToast = Toast.makeText(this, "", Toast.LENGTH_SHORT);

    // Show the Up button in the action bar.
    setupActionBar();//from  w  w  w.ja va 2 s .  co  m

    TextView sourceText = (TextView) findViewById(id.about_source_text);
    sourceText.setMovementMethod(LinkMovementMethod.getInstance());
    TextView bugsText = (TextView) findViewById(id.about_bugs_text);
    bugsText.setMovementMethod(LinkMovementMethod.getInstance());
    TextView commentsText = (TextView) findViewById(id.about_comments_text);
    commentsText.setMovementMethod(LinkMovementMethod.getInstance());

    TextView versionText = (TextView) findViewById(id.about_version_number);
    String formattedVersion = String.format(getString(R.string.about_version), Versioning.getVersionCode());
    versionText.setText(formattedVersion);

    TextView basicOrPro = (TextView) findViewById(id.about_version_pro);
    String type;
    Authenticator authenticator = new Authenticator(this);
    if (authenticator.isAuthenticated()) {
        type = "Pro version";
    } else {
        type = "Basic version";
    }
    basicOrPro.setText(type);

    final View betaSettingsHeaderContent = findViewById(id.about_header_beta_settings);
    betaSettingsHeaderContent.setOnTouchListener(mOnTouch);
    final View normalHeaderContent = findViewById(id.about_header_normal);
    normalHeaderContent.setOnTouchListener(mOnTouch);
    normalHeaderContent.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            toggleVisibility(normalHeaderContent);
            return true;
        }
    });
    betaSettingsHeaderContent.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            toggleVisibility(normalHeaderContent);
            return true;
        }
    });

    final View betaSettingsClickArea = findViewById(id.about_header_beta_settings_clickarea);
    betaSettingsClickArea.setOnTouchListener(mOnTouch);
    final SwitchCompat betaSettingsSwitch = (SwitchCompat) findViewById(id.about_header_beta_settings_switch);
    final BetaPrefs betaPrefs = new BetaPrefs(this);
    betaSettingsSwitch.setChecked(betaPrefs.isBetaPrefsUnlocked());
    betaSettingsClickArea.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            betaSettingsSwitch.performClick();
            betaPrefs.setIsBetaPrefsUnlocked(betaSettingsSwitch.isChecked());
        }
    });
    betaSettingsClickArea.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            toggleVisibility(normalHeaderContent);
            return true;
        }
    });
}

From source file:com.wordpress.ebc81.rtl_ais_android.tools.DialogManager.java

/**
 * Add new dialogs here!//  w ww. j av a  2s .com
 * @param id
 * @param args
 * @return
 */
private Dialog createDialog(final dialogs id, final String[] args) {
    switch (id) {
    case DIAG_LIST_USB:
        return genUSBDeviceDialog();
    case DIAG_ABOUT:
        final AlertDialog addd = new AlertDialog.Builder(getActivity()).setTitle(R.string.help)
                .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }).setMessage(Html.fromHtml(getString(R.string.help_info))).create();
        try {
            addd.setOnShowListener(new DialogInterface.OnShowListener() {

                @Override
                public void onShow(DialogInterface paramDialogInterface) {
                    try {
                        final TextView tv = (TextView) addd.getWindow().findViewById(android.R.id.message);
                        if (tv != null)
                            tv.setMovementMethod(LinkMovementMethod.getInstance());

                    } catch (Exception e) {
                    }
                }
            });
        } catch (Exception e) {
        }

        return addd;
    case DIAG_LICENSE:
        return new AlertDialog.Builder(getActivity()).setTitle("COPYING")
                .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }).setMessage(readWholeStream("COPYING")).create();
    }
    return null;
}

From source file:org.ciasaboark.tacere.activity.fragment.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_about, container, false);
    context = getActivity();//from   w ww.j a  va2s.  c  o  m

    ongoingToast = Toast.makeText(context, "", Toast.LENGTH_SHORT);

    TextView sourceText = (TextView) rootView.findViewById(id.about_source_text);
    sourceText.setMovementMethod(LinkMovementMethod.getInstance());
    TextView bugsText = (TextView) rootView.findViewById(id.about_bugs_text);
    bugsText.setMovementMethod(LinkMovementMethod.getInstance());
    TextView commentsText = (TextView) rootView.findViewById(id.about_comments_text);
    commentsText.setMovementMethod(LinkMovementMethod.getInstance());

    TextView versionText = (TextView) rootView.findViewById(id.about_version_number);
    String formattedVersion = String.format(getString(R.string.about_version), Versioning.getVersionCode());
    versionText.setText(formattedVersion);
    //textview using marquee scrolling, but this only works if the textview is selected
    versionText.setSelected(true);

    TextView versionType = (TextView) rootView.findViewById(id.about_version_type);
    String type;
    Authenticator authenticator = new Authenticator(context);
    type = authenticator.getAuthenticatedTypeString() + " version";
    versionType.setText(type);

    final View betaSettingsHeaderContent = rootView.findViewById(id.about_header_beta_settings);
    betaSettingsHeaderContent.setOnTouchListener(mOnTouch);
    final View normalHeaderContent = rootView.findViewById(id.about_header_normal);
    normalHeaderContent.setOnTouchListener(mOnTouch);
    normalHeaderContent.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            toggleVisibility(normalHeaderContent);
            return true;
        }
    });
    betaSettingsHeaderContent.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            toggleVisibility(normalHeaderContent);
            return true;
        }
    });

    final View betaSettingsClickArea = rootView.findViewById(id.about_header_beta_settings_clickarea);
    betaSettingsClickArea.setOnTouchListener(mOnTouch);
    final SwitchCompat betaSettingsSwitch = (SwitchCompat) rootView
            .findViewById(id.about_header_beta_settings_switch);
    final BetaPrefs betaPrefs = new BetaPrefs(context);
    betaSettingsSwitch.setChecked(betaPrefs.isBetaPrefsUnlocked());
    betaSettingsClickArea.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            betaSettingsSwitch.performClick();
            betaPrefs.setIsBetaPrefsUnlocked(betaSettingsSwitch.isChecked());
        }
    });
    betaSettingsClickArea.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            toggleVisibility(normalHeaderContent);
            return true;
        }
    });

    return rootView;
}

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

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    root = inflater.inflate(R.layout.regional_happenings, null, false);
    title = (TextView) root.findViewById(R.id.regional_happenings_header);
    list = (ListView) root.findViewById(R.id.regional_happenings_list);
    layout = (ViewGroup) root.findViewById(R.id.layout);
    ViewTreeObserver observer = title.getViewTreeObserver();
    observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
        @Override/*from  w  w  w  .  ja va  2 s .  c  o  m*/
        public void onGlobalLayout() {
            layout.setPadding(layout.getPaddingLeft(),
                    title.getHeight() - (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 15,
                            getResources().getDisplayMetrics()),
                    layout.getPaddingRight(), layout.getPaddingBottom());
        }
    });

    happenings = new ArrayList<RegionHappening>();
    listAdapter = new ArrayAdapter<RegionHappening>(context, 0, happenings) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view;
            TextView msg;

            if (convertView == null) {
                view = inflater.inflate(R.layout.event, null);
                msg = (TextView) view.findViewById(R.id.event_message);
                msg.setMovementMethod(LinkMovementMethod.getInstance());
            } else {
                view = convertView;
                msg = (TextView) view.findViewById(R.id.event_message);
            }
            RegionHappening event = getItem(position);
            long timestamp = event.timestamp;
            String time = TagParser.parseTimestamp(getContext(), timestamp);
            String text = time + ": " + event.text;
            //              text = text.replaceAll("@@([a-z\\d_]+)@@",
            //                    "<a href=\"com.limewoodMedia.nsdroid.nation://$1\">$1</a>");
            //              text = text.replaceAll("%%([a-z\\d_]+)%%",
            //                    "<a href=\"com.limewoodMedia.nsdroid.region://$1\">$1</a>");
            msg.setText(Html.fromHtml(text));

            return view;
        }
    };
    list.setAdapter(listAdapter);
    LoadingHelper.startLoading((com.limewoodmedia.nsdroid.views.LoadingView) root.findViewById(R.id.loading));

    return root;
}

From source file:com.github.michalbednarski.intentslab.providerlab.ProviderInfoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.activity_provider_info, container, false);

    mPackageName = getArguments().getString(ComponentInfoFragment.ARG_PACKAGE_NAME);
    mComponentName = getArguments().getString(ComponentInfoFragment.ARG_COMPONENT_NAME);

    // Fill mProviderInfo
    try {/*w  w  w .  j  a  va  2s  . com*/
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
            fillProviderInfo();
        } else {
            fillProviderInfoLegacy();
        }
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
        Toast.makeText(getActivity(), R.string.component_not_found, Toast.LENGTH_SHORT).show();
        //finish();
        return null;
    }

    PackageManager packageManager = getActivity().getPackageManager();

    // Header icon and text
    ((TextView) view.findViewById(R.id.title)).setText(mProviderInfo.loadLabel(packageManager));
    ((TextView) view.findViewById(R.id.component))
            .setText(new ComponentName(mPackageName, mComponentName).flattenToShortString());
    ((ImageView) view.findViewById(R.id.icon)).setImageDrawable(mProviderInfo.loadIcon(packageManager));

    // Start building description
    FormattedTextBuilder text = new FormattedTextBuilder();

    // Authority
    if (mProviderInfo.authority != null) {
        text.appendValue("Authority", mProviderInfo.authority);
    }

    // Permission/exported
    if (!mProviderInfo.exported) {
        text.appendHeader(getString(R.string.component_not_exported));
    } else {
        if (mProviderInfo.readPermission == null) {
            if (mProviderInfo.writePermission == null) {
                text.appendHeader(getString(R.string.provider_rw_world_accessible));
            } else {
                text.appendValue(getString(R.string.provider_w_only_permission), mProviderInfo.writePermission,
                        true, FormattedTextBuilder.ValueSemantic.PERMISSION);
            }
        } else if (mProviderInfo.readPermission.equals(mProviderInfo.writePermission)) {
            text.appendValue(getString(R.string.provider_rw_permission), mProviderInfo.readPermission, true,
                    FormattedTextBuilder.ValueSemantic.PERMISSION);
        } else {
            text.appendValue(getString(R.string.provider_r_permission), mProviderInfo.readPermission, true,
                    FormattedTextBuilder.ValueSemantic.PERMISSION);
            if (mProviderInfo.writePermission == null) {
                text.appendValuelessKeyContinuingGroup(
                        getResources().getText(R.string.provider_no_w_permission));
            } else {
                text.appendValue(getString(R.string.provider_w_permission), mProviderInfo.writePermission,
                        false, FormattedTextBuilder.ValueSemantic.PERMISSION);
            }
        }
    }

    // Permission granting
    if (mProviderInfo.grantUriPermissions) {
        if (mProviderInfo.uriPermissionPatterns != null) {
            PatternMatcher[] uriPermissionPatterns = mProviderInfo.uriPermissionPatterns;
            String[] listItems = new String[uriPermissionPatterns.length];
            for (int i = 0; i < uriPermissionPatterns.length; i++) {
                PatternMatcher pattern = uriPermissionPatterns[i];
                listItems[i] = pattern.getPath()
                        + (pattern.getType() == PatternMatcher.PATTERN_PREFIX ? "*" : "");
            }
            text.appendList(getString(R.string.provider_grant_uri_permission_for), listItems);
        } else {
            text.appendHeader(getString(R.string.provider_grant_uri_permission_for_all_paths));
        }
    }

    // <meta-data>
    text.appendFormattedText(
            ComponentInfoFragment.dumpMetaData(getActivity(), mPackageName, mProviderInfo.metaData));

    // Put description in TextView
    TextView textView = (TextView) view.findViewById(R.id.description);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setText(text.getText());

    // Set button action
    view.findViewById(R.id.go_to_provider_lab).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            goToProviderLab();
        }
    });

    // Return view
    return view;
}

From source file:org.angellist.angellistmobile.FeedJSONAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null)
        convertView = activity.getLayoutInflater().inflate(R.layout.row_feed, null);

    TextView textView = (TextView) convertView.findViewById(R.id.label);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    ImageView imageView = (ImageView) convertView.findViewById(R.id.logo);
    JSONObject jsonObject = getItem(position);

    try {//w w  w . j av a  2 s .c  o m

        String type = null;

        type = jsonObject.getJSONObject("item").getString("type");

        textView.setText("-");
        imageView.setImageResource(R.drawable.ic_launcher);
        Log.d(type, jsonObject.toString());
        String image = jsonObject.getJSONObject("actor").getString("image");
        imageLoader.DisplayImage(image, imageView);
        if ("Follow".equals(type)) {
            // follow
            // {"timestamp":"2013-10-17T15:16:46Z","id":"UyroZ","text":null,"promoted_by":[],"extra":null,"description":"<a
            // href=\"https:\/\/angel.co\/sbergel\" class=\"feed_link\"
            // data-id=\"106927\" data-type=\"User\">Shanti Bergel<\/a>
            // followed <a href=\"https:\/\/angel.co\/softbank-capital\"
            // class=\"feed_link\" data-id=\"79702\"
            // data-type=\"Startup\">SoftBank
            // Capital<\/a>","likes":0,"item":{"type":"Follow","ids":[15308380]},"target":{"id":79702,"image":"https:\/\/s3.amazonaws.com\/photos.angel.co\/startups\/i\/79702-06c0b2126476861a1ae5cfb92da2a1aa-thumb_jpg.jpg?buster=1333126870","system_user?":null,"type":"Startup","angellist_url":"https:\/\/angel.co\/softbank-capital","tagline":"Multi-stage
            // venture fund w\/ $600mm under management delivering strategic
            // value to founders","name":"SoftBank
            // Capital"},"actor":{"id":106927,"image":"https:\/\/s3.amazonaws.com\/photos.angel.co\/users\/106927-medium_jpg?1331913511","system_user?":false,"type":"User","angellist_url":"https:\/\/angel.co\/sbergel","tagline":"Business
            // & Corporate Development Black Belt  Founder @qbiquity  Exec
            // roles at @playfish, @gree","name":"Shanti
            // Bergel"},"comments":0}

            String descriptionHtml = jsonObject.getString("description");
            String description = this.replaceUserAndStartupLinks(descriptionHtml);
            textView.setText(Html.fromHtml(description));

        } else if ("Press".equals(type)) {
            // press
            // {"timestamp":"2013-10-17T15:35:03Z","id":"Uyshy","text":"<a
            // href=\"http:\/\/philadelphia.cbslocal.com\/2013\/10\/14\/boppl-app\/\"
            // target=\"_blank\">CBS Philadelphia features
            // Boppl<\/a>","promoted_by":[],"extra":null,"description":"<a
            // href=\"https:\/\/angel.co\/boppl\" class=\"feed_link\"
            // data-id=\"154252\" data-type=\"Startup\">Boppl<\/a> added
            // press from
            // philadelphia.cbslocal.com","likes":0,"item":{"type":"Press","ids":[85539]},"target":null,"actor":{"id":154252,"image":"https:\/\/s3.amazonaws.com\/photos.angel.co\/startups\/i\/154252-6e332013f324434792202151e21d8435-thumb_jpg.jpg?buster=1375709358","system_user?":null,"type":"Startup","angellist_url":"https:\/\/angel.co\/boppl","tagline":"Order
            // and pay for food and drinks","name":"Boppl"},"comments":0}
            String descriptionHtml = jsonObject.getString("description");
            String description = this.replaceUserAndStartupLinks(descriptionHtml);
            textView.setText(Html.fromHtml(description));
        } else if ("StartupRole".equals(type)) {
            // startuprole
            // {"timestamp":"2013-10-17T15:30:29Z","id":"Uys8P","text":null,"promoted_by":[],"extra":{"comment":null},"description":"<a
            // href=\"https:\/\/angel.co\/jim-huston\" class=\"feed_link\"
            // data-id=\"104534\" data-type=\"User\">Jim Huston<\/a>
            // invested in <a href=\"https:\/\/angel.co\/onthego-platforms\"
            // class=\"feed_link\" data-id=\"123266\"
            // data-type=\"Startup\">OnTheGo Platforms<\/a>'s previous
            // round","likes":0,"item":{"type":"StartupRole","ids":[902050]},"target":{"id":123266,"image":"https:\/\/s3.amazonaws.com\/photos.angel.co\/startups\/i\/123266-001115ef9a121690432a5a43ae7515c5-thumb_jpg.jpg?buster=1364053321","system_user?":null,"type":"Startup","angellist_url":"https:\/\/angel.co\/onthego-platforms","tagline":"Our
            // software makes smart glasses easier to use and the
            // applications on them more powerful.","name":"OnTheGo
            // Platforms"},"actor":{"id":104534,"image":"https:\/\/s3.amazonaws.com\/photos.angel.co\/users\/104534-medium_jpg?1331270245","system_user?":false,"type":"User","angellist_url":"https:\/\/angel.co\/jim-huston","tagline":"Early
            // Stage Seed Investor at Portland Seed Fund","name":"Jim
            // Huston"},"comments":0}
            String descriptionHtml = jsonObject.getString("description");
            String description = this.replaceUserAndStartupLinks(descriptionHtml);
            textView.setText(Html.fromHtml(description));
        } else if ("StatusUpdate".equals(type)) {
            // statusupdate
            // {"timestamp":"2013-10-17T15:11:37Z","id":"UyriB","text":"Haxlr8r
            // Demo Day (III) is coming up on 21 November 2013 in San
            // Fran... Contact Cyril or me to get on the RSVP list... Flying
            // robots, Batman! See some of our breakout companies here:
            // http:\/\/kickstarter\/haxlr8r","promoted_by":[],"extra":null,"description":"<a
            // href=\"https:\/\/angel.co\/sosventures\" class=\"feed_link\"
            // data-id=\"33924\" data-type=\"User\">Sean O&#39;Sullivan<\/a>
            // updated their
            // status","likes":0,"item":{"type":"StatusUpdate","ids":[112276]},"target":null,"actor":{"id":33924,"image":"https:\/\/s3.amazonaws.com\/photos.angel.co\/users\/33924-medium_jpg?1305992664","system_user?":false,"type":"User","angellist_url":"https:\/\/angel.co\/sosventures","tagline":"founder
            // of @carma-3, JumpStart Int'l, @mapinfo; co-inventor of street
            // mapping on PCs. co-coined term
            // \"cloud computing\" in 1996. seed & venture capital investor.","name":"Sean O'Sullivan"},"comments":0}

            String descriptionHtml = jsonObject.getString("description");
            String description = this.replaceUserAndStartupLinks(descriptionHtml);
            description = description + "<br>" + jsonObject.getString("text");
            textView.setText(Html.fromHtml(description));
        } else if ("Reservation".equals(type)) {
            String descriptionHtml = jsonObject.getString("description");
            String description = this.replaceUserAndStartupLinks(descriptionHtml);
            textView.setText(Html.fromHtml(description));
        } else if ("Review".equals(type)) {
            String descriptionHtml = jsonObject.getString("description");
            String description = this.replaceUserAndStartupLinks(descriptionHtml);
            description = description + "<br>" + jsonObject.getString("text");
            textView.setText(Html.fromHtml(description));
        } else if ("JobListing".equals(type)) {
            String descriptionHtml = jsonObject.getString("description");
            String description = this.replaceUserAndStartupLinks(descriptionHtml);
            textView.setText(Html.fromHtml(description));
        } else if ("StartupPublish".equals(type)) {
            String descriptionHtml = jsonObject.getString("description");
            String description = this.replaceUserAndStartupLinks(descriptionHtml);
            textView.setText(Html.fromHtml(description));
        } else if ("Share".equals(type)) {
            String descriptionHtml = jsonObject.getString("description");
            String description = this.replaceUserAndStartupLinks(descriptionHtml);
            textView.setText(Html.fromHtml(description));
        } else {
            textView.setText(type);

        }

    } catch (JSONException e) {
        e.printStackTrace();
    }

    return convertView;
}

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

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    root = inflater.inflate(R.layout.national_happenings, null, false);
    list = (ListView) root.findViewById(R.id.national_happenings_list);
    layout = (ViewGroup) root.findViewById(R.id.layout);
    title = (TextView) root.findViewById(R.id.national_happenings_header);
    ViewTreeObserver observer = title.getViewTreeObserver();
    observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
        @Override/*  w w w . ja v  a 2 s . c o m*/
        public void onGlobalLayout() {
            layout.setPadding(layout.getPaddingLeft(),
                    title.getHeight() - (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 15,
                            getResources().getDisplayMetrics()),
                    layout.getPaddingRight(), layout.getPaddingBottom());
        }
    });

    happenings = new ArrayList<NationHappening>();
    listAdapter = new ArrayAdapter<NationHappening>(context, 0, happenings) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view;
            TextView msg;

            if (convertView == null) {
                view = inflater.inflate(R.layout.event, null);
                msg = (TextView) view.findViewById(R.id.event_message);
                msg.setMovementMethod(LinkMovementMethod.getInstance());
            } else {
                view = convertView;
                msg = (TextView) view.findViewById(R.id.event_message);
            }
            NationHappening event = getItem(position);
            long timestamp = event.timestamp;
            String time = TagParser.parseTimestamp(getContext(), timestamp);
            String text = time + ": " + event.text;
            //             text = text.replaceAll("@@("+nation.toLowerCase().replace(' ', '_')+")@@",
            //                    "<a href=\"com.limewoodMedia.nsdroid.nation://$1\">"+nation+"</a>");
            //             text = text.replaceAll("@@([a-z\\d_]+)@@",
            //                    "<a href=\"com.limewoodMedia.nsdroid.nation://$1\">$1</a>");
            //             text = text.replaceAll("%%("+region.toLowerCase().replace(' ', '_')+")%%",
            //                    "<a href=\"com.limewoodMedia.nsdroid.region://$1\">"+region+"</a>");
            //              text = text.replaceAll("%%([a-z\\d_]+)%%",
            //                    "<a href=\"com.limewoodMedia.nsdroid.region://$1\">$1</a>");
            //              text = text.replaceAll("%%([a-z\\d_]+)%rmb%%",
            //                    "<a href=\"com.limewoodMedia.nsdroid.region.rmb://$1\">Regional Message Board</a>");
            msg.setText(Html.fromHtml(text));

            return view;
        }
    };
    list.setAdapter(listAdapter);
    LoadingHelper.startLoading((com.limewoodmedia.nsdroid.views.LoadingView) root.findViewById(R.id.loading));

    return root;
}