Code example for TextSwitcher

Methods: getChildAt, setText, setVisibility

0
	 * @param websiteUrl The URL that the label links to. 
	 */ 
	protected void setAndLinkifyWebsiteLink(final String websiteLabel, final String websiteUrl) {
		if (!TextUtils.isEmpty(websiteUrl)) {
			if (TextUtils.isEmpty(websiteLabel)) {
				mWebsiteText.setText(websiteUrl);
			} else { 
				mWebsiteText.setText(websiteLabel);
			} 
			mWebsiteText.setVisibility(View.VISIBLE);
			 
			//Create TransformFilter 
			TransformFilter tf = new TransformFilter() {
	 
				public String transformUrl(final Matcher matcher,
						final String url) {
					return websiteUrl;
				} 
				 
			}; 
			 
			//Allow a label and url through Linkify 
			Linkify.addLinks((TextView) mWebsiteText.getChildAt(0), Pattern
					.compile(".*"), "", null, tf);
			Linkify.addLinks((TextView) mWebsiteText.getChildAt(1), Pattern
					.compile(".*"), "", null, tf);
		} else { 
			mWebsiteText.setVisibility(View.GONE);
		} 
	}