初识安卓

来源:互联网 发布:js阻止事件冒泡 编辑:程序博客网 时间:2024/05/23 19:13
package com.example.hellowidgets;import android.os.Bundle;import android.app.Activity;import android.graphics.Bitmap;import android.graphics.BitmapFactory;import android.text.Html;import android.text.Spannable;import android.text.SpannableString;import android.text.style.DynamicDrawableSpan;import android.text.style.ImageSpan;import android.view.Menu;import android.widget.TextView;public class MaaaaActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_maaaa);TextView tv=(TextView) findViewById(R.id.textView12);tv.setTextSize(20);tv.setText("\n菜鸟思密达");tv.setBackgroundColor(34);//html文本TextView tv1=(TextView) findViewById(R.id.htmltextview);String html="我html字符串
超级链接百度";tv1.setText(Html.fromHtml(html));//图文混排Bitmap b=BitmapFactory.decodeResource(getResources(),R.drawable.miedao );ImageSpan imgSpan=new ImageSpan(this,b,DynamicDrawableSpan.ALIGN_BOTTOM);SpannableString spanString=new SpannableString("icon");spanString.setSpan(imgSpan, 0, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);TextView tv2=(TextView) findViewById(R.id.htmltextview);tv2.setText("图文混排");tv2.append(spanString);tv2.append("我是追加文本");}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.maaaa, menu);return true;}}
0 0
原创粉丝点击