1 package com.example.suneyaenews; 2 3 import java.util.ArrayList; 4 import java.util.HashMap; 5 import java.util.List; 6 7 import android.app.Activity; 8 import android.graphics.Bitmap; 9 import android.graphics.Canvas; 10 import android.graphics.Paint; 11 import android.os.Bundle; 12 import android.text.Html; 13 import android.view.LayoutInflater; 14 import android.view.Menu; 15 import android.view.MenuItem; 16 import android.view.View; 17 import android.view.View.OnClickListener; 18 import android.widget.Button; 19 import android.widget.ImageView; 20 import android.widget.ListView; 21 import android.widget.SimpleAdapter; 22 import android.widget.TextView; 23 import android.widget.Toast; 24 import android.widget.ViewFlipper; 25 26 public class DetailActivity extends Activity { 27 private ViewFlipper mNewsbodyFilpper; 28 private LayoutInflater mNewsBodyInflater; 29 30 private TextView tv_news_title,tv_news_body; 31 private final String NEWS = "<p>这是正文部分</p><input type=‘button‘ value=‘xx‘ /><br/>哈哈"; 32 @Override 33 protected void onCreate(Bundle savedInstanceState) { 34 super.onCreate(savedInstanceState); 35 setContentView(R.layout.newsdetail); 36 37 mNewsbodyFilpper = (ViewFlipper) findViewById(R.id.id_viewflipper); 38 mNewsBodyInflater = getLayoutInflater(); 39 View newsBodyView = mNewsBodyInflater.inflate(R.layout.news_body, null); 40 tv_news_title = (TextView) newsBodyView.findViewById(R.id.id_news_body_title); 41 tv_news_body = (TextView) newsBodyView.findViewById(R.id.id_news_body_zhengwen); 42 tv_news_title = (TextView) findViewById(R.id.id_news_body_title); 43 tv_news_body = (TextView) findViewById(R.id.id_news_body_zhengwen); 44 tv_news_title.setText("weiyl标题"); 45 tv_news_body.setText(Html.fromHtml(NEWS)); 46 47 View newsBodyView2 = mNewsBodyInflater.inflate(R.layout.news_body, null); 48 tv_news_title = (TextView) newsBodyView2.findViewById(R.id.id_news_body_title); 49 tv_news_body = (TextView) newsBodyView2.findViewById(R.id.id_news_body_zhengwen); 50 51 tv_news_title = (TextView) findViewById(R.id.id_news_body_title); 52 tv_news_body = (TextView) findViewById(R.id.id_news_body_zhengwen); 53 tv_news_title.setText("weiyl标题2"); 54 tv_news_body.setText(Html.fromHtml(NEWS)); 55 56 mNewsbodyFilpper.addView(newsBodyView); 57 mNewsbodyFilpper.addView(newsBodyView2); 58 59 } 60 61 62 63 64 }
原文:http://www.cnblogs.com/Sunnor/p/5457011.html