• Android


     /**
     * @Title CustomWidgeActivity.java
     * @package     cn.boxai.customview
     * @since  
     * @version     1.0.0 
     * @author      Vic Lee
     * @date        Aug 22, 2016-8:15:35 PM
     */
    package cn.boxai.customview;
    
    import android.R.string;
    import android.app.Activity;
    import android.graphics.drawable.BitmapDrawable;
    import android.graphics.drawable.Drawable;
    import android.os.Bundle;
    import android.text.Html;
    import android.text.Html.ImageGetter;
    import android.text.Spannable;
    import android.text.SpannableStringBuilder;
    import android.text.style.ClickableSpan;
    import android.text.style.ImageSpan;
    import android.view.View;
    import android.widget.TextView;
    import android.widget.Toast;
    
    public class CustomWidgeActivity extends Activity {
    TextView mTextView;
    ImageGetter getter;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            
            
            super.onCreate(savedInstanceState);
            
            setContentView(R.layout.activity_customwidge);
            showTextView() ;
            
            
            
            
        }
    protected void showTextView() 
    {
    //    getter=new  ImageGetter() 
    //    {
    //        
    //        @Override
    //        public Drawable getDrawable(String source) {
    //            if (source!=null) 
    //            {
    //                BitmapDrawable bitmapDrawable=(BitmapDrawable) getResources().getDrawable(R.drawable.aa);
    //             bitmapDrawable.setBounds(0, 0,bitmapDrawable.getIntrinsicWidth(), bitmapDrawable.getIntrinsicWidth());
    //                return bitmapDrawable;
    //            }
    //            else 
    //            {
    //                return null;    
    //            }
    //            
    //        }
    //    };    
    //    mTextView=(TextView) findViewById(R.id.textView1);
    //    String html="<h1>ddddddddddddsfsf</h1></br>ddddddd </br><img src='http://pic.cnblogs.com/face/800469/20160120232307.png'/ ddsfdsaf>";
    //    mTextView.setText(Html.fromHtml(html, getter, null));
        
        mTextView=(TextView) findViewById(R.id.textView1);
        SpannableStringBuilder spannableStringBuilder=new  SpannableStringBuilder(" hello world!");
        ImageSpan imageSpan=new  ImageSpan(CustomWidgeActivity.this,R.drawable.aa);
        ClickableSpan clickableSpan=new  ClickableSpan() {
            
            @Override
            public void onClick(View widget) {
            Toast.makeText(CustomWidgeActivity.this, " you are click", 3000).show();
            }
        };
        
        spannableStringBuilder.setSpan(imageSpan, 3, 5, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        spannableStringBuilder.setSpan(clickableSpan, 0, 4, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
        mTextView.setText(spannableStringBuilder);
    
    }
        
    }

  • 相关阅读:
    nexus3.x Liunx私库安装教程 (亲测有用)
    nexus 3.x下载 3.18.1(maven 私服)
    halo项目源码本地部署解决方案
    gradle的安装配置
    raw.githubusercontent.com 访问不了
    springboot使用quartz解决调用不到spring注入service的问题
    Linux在不能使用yum的环境下安装pgsql(公司内网)
    idea 里面的maven依赖下载不了,以及mabtis依赖包错误
    关于oracle 数据库效率的优化
    关于oracle 不常用的job 运行时间设置
  • 原文地址:https://www.cnblogs.com/laopo/p/5797882.html
Copyright © 2020-2023  润新知