AbsoluteLayout 相框
生活随笔
收集整理的這篇文章主要介紹了
AbsoluteLayout 相框
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
xiangkuang.java
public class xiangkuang extends Activity {/*聲明 Button、ImageView對象*/private ImageView mImageView01;private ImageView mImageView02;private Button mButton01;private Button mButton02;/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);/*取得 Button、ImageView對象*/mImageView01 = (ImageView)findViewById(R.id.myImageView1);mImageView02 = (ImageView)findViewById(R.id.myImageView2);mButton01 = (Button) findViewById(R.id.myButton1);mButton02 = (Button) findViewById(R.id.myButton2);/*設置ImageView背景圖*/mImageView01.setImageDrawable(getResources().getDrawable(R.drawable.right)); mImageView02.setImageDrawable(getResources().getDrawable(R.drawable.aaa));/*用OnClickListener事件來啟動*/mButton01.setOnClickListener(new Button.OnClickListener(){@Overridepublic void onClick(View v){/*當啟動后,ImageView立刻換背景圖*/ mImageView01.setImageDrawable(getResources().getDrawable(R.drawable.right));}});mButton02.setOnClickListener(new Button.OnClickListener(){@Overridepublic void onClick(View v){mImageView01.setImageDrawable(getResources().getDrawable(R.drawable.left));}});} }main.xml <?xml version="1.0" encoding="utf-8"?> <AbsoluteLayoutandroid:id="@+id/widget34"android:layout_width="fill_parent"android:layout_height="fill_parent"xmlns:android="http://schemas.android.com/apk/res/android"><ImageViewandroid:id="@+id/myImageView1"android:layout_width="320px"android:layout_height="280px"android:layout_x="0px"android:layout_y="36px"/><ImageViewandroid:id="@+id/myImageView2"android:layout_width="104px"android:layout_height="157px"android:layout_x="101px"android:layout_y="119px"/><Buttonandroid:id="@+id/myButton1"android:layout_width="105px"android:layout_height="66px"android:text="圖片1"android:layout_x="9px"android:layout_y="356px"/><!--建立第二個Button --><Buttonandroid:id="@+id/myButton2"android:layout_width="105px"android:layout_height="66px"android:text="圖片2"android:layout_x="179px"android:layout_y="356px"/> </AbsoluteLayout>
轉載于:https://www.cnblogs.com/flyingsir/archive/2012/08/29/3983751.html
總結
以上是生活随笔為你收集整理的AbsoluteLayout 相框的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: poj 3304 Segments
- 下一篇: 三大资产是哪三大资产