Step 1: display an image: method 1. Public class picshowmainactivity extends activity {linearlayout mlinearlayout; @ overrideprotected void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); this. mlinearlayout = new linearlayout (this); imageview I = new imageview (this); I. setimageresource (R. drawable. heHua); I. setadjustviewbounds (true); I. setlayoutparams (new gallery. layoutparams (layoutparams. wrap_content, layoutparams. wrap_content); mlinearlayout. addview (I); setcontentview (mlinearlayout); // setcontentview (R. layout. main) ;}@ overridepublic Boolean oncreateoptionsmenu (menu) {// inflate the menu; this adds items to the action bar if it is present. getmenuinflater (). inflate (R. menu. main, menu); Return true ;}}
Method 2:
public class PicshowMainActivity extends Activity {LinearLayout mLinearLayout;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);this.mLinearLayout = new LinearLayout(this);ImageView i = new ImageView(this);//i.setAdjustViewBounds(adjustViewBounds)//i.setImageResource(R.drawable.hehua);i.setAdjustViewBounds(true);i.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));//mLinearLayout.addView(i);//setContentView(mLinearLayout);//ContextWrapper mContext = null;Resources res = getResources();Drawable myImage = res.getDrawable(R.drawable.baihehua);//TransitionDrawable transition = (TransitionDrawable)res.getDrawable(R.drawable.hehua);//TransitionDrawable transition =//(TransitionDrawable) res.getDrawable(R.drawable.next);//i.setImageDrawable(transition);i.setImageDrawable(myImage);//transition.startTransition(10000);mLinearLayout.addView(i);setContentView(mLinearLayout);//setContentView(R.layout.main);}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}}
Method 3:
Yescontrol display omitted