• AbsoluteLayout xiantu



    xiantu.java

    public class xiantu extends Activity
    {
      /*声明对象变量*/
      private ImageView mImageView;
      private Button mButton;
      private TextView mTextView;
      private String fileName="/data/data/irdc.ex04_22/ex04_22_2.png";
      
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
        super.onCreate(savedInstanceState);
        /* 载入main.xml Layout */
        setContentView(R.layout.main);
        
        /* 取得Button对象,并添加onClickListener */
        mButton = (Button)findViewById(R.id.mButton);
        mButton.setOnClickListener(new Button.OnClickListener()
        {
          public void onClick(View v)
          {
          /* 取得对象 */
            mImageView = (ImageView)findViewById(R.id.mImageView);
            mTextView=(TextView)findViewById(R.id.mTextView);
            /* 检查文件是否存在 */
            File f=new File(fileName);   
            if(f.exists()) 
            { 
              /* 产生Bitmap对象,并放入mImageView中 */
              Bitmap bm = BitmapFactory.decodeFile(fileName);
              mImageView.setImageBitmap(bm);
              mTextView.setText(fileName); 
            } 
            else 
            {  
              mTextView.setText("此文件不存在"); 
            }
          } 
        });
      }
    }

    main.xml

    <?xml version="1.0" encoding="utf-8"?>
      <AbsoluteLayout
        android:id="@+id/layout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/white"
        xmlns:android="http://schemas.android.com/apk/res/android"
      >
        <TextView 
          android:id="@+id/mTextView" 
          android:layout_width="fill_parent"  
          android:layout_height="wrap_content"  
          android:text="@string/str_text"
          android:layout_x="30px"
          android:layout_y="30px"
          android:textColor="@drawable/blue"
        >
        </TextView> 
        <ImageView
          android:id="@+id/mImageView"
          android:layout_width="250px"
          android:layout_height="188px"
          android:src="@drawable/example060"
          android:layout_x="30px"
          android:layout_y="62px"
        >
        </ImageView>
        <Button
          android:id="@+id/mButton"
          android:layout_width="155px"
          android:layout_height="wrap_content"
          android:text="@string/str_button"
          android:textSize="18sp"
          android:layout_x="80px"
          android:layout_y="302px"
        >
        </Button>
      </AbsoluteLayout>
    








  • 相关阅读:
    bash组织成树数据结构
    statickeyword于C和C++用法
    POJ2239 Selecting Courses【二部图最大匹配】
    MVC过滤器的详细讲解和示范样本
    hdoj 2602 Bone Collector 【01背包】
    下的生产环境was重新启动不同意,怎么做?
    Qt Model/View 的简单说明
    View与Model绑定注意事项 (视图无数据显示)
    Qt Delgate的使用 简单说明
    QAbstractTableModel中的data()到底执行几遍???
  • 原文地址:https://www.cnblogs.com/flyingsir/p/3983750.html
Copyright © 2020-2023  润新知