Ejemplo n.º 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.test_viewgroup);

    mViewGroup = (MyViewGroup) findViewById(R.id.test_view_group);

    ImageView imgView = new ImageView(this);
    imgView.setImageResource(R.drawable.sbook1);
    imgView.setPadding(0, 10, 0, 10);
    mViewGroup.addView(imgView);

    ImageView imgView2 = new ImageView(this);
    imgView2.setImageResource(R.drawable.sbook2);
    imgView2.setPadding(0, 10, 0, 10);
    mViewGroup.addView(imgView2);

    DisplayMetrics metrics = getResources().getDisplayMetrics();
    Log.e("TAG", "(" + metrics.widthPixels + "," + metrics.heightPixels + ")");

    /*
    int width = 1073742544;
    int height = 1073742862;

    int wMode = View.MeasureSpec.getMode(width);
    int wSize = View.MeasureSpec.getSize(width);

    int hMode = View.MeasureSpec.getMode(height);
    int hSize = View.MeasureSpec.getSize(height);

    Log.e("TAG", "wMode=" + wMode + ",wSize=" + wSize + ",hMode=" + hMode + ",hSize=" + hSize);
    */
  }
Ejemplo n.º 2
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);
    viewGroup = (MyViewGroup) findViewById(R.id.myViewGroup);

    ImageView imageView = new ImageView(this);
    imageView.setImageDrawable(getResources().getDrawable(R.drawable.a1));
    viewGroup.addView(imageView);

    viewGroup.addView(View.inflate(this, R.layout.form, null));

    findViewById(R.id.Button01)
        .setOnClickListener(
            new View.OnClickListener() {

              @Override
              public void onClick(View v) {
                // TODO Auto-generated method stub
                System.out.println("©ирт╣Ц╩В");
              }
            });

    imageView = new ImageView(this);
    imageView.setImageDrawable(getResources().getDrawable(R.drawable.a2));
    viewGroup.addView(imageView);

    pageControl = (PageControlView) findViewById(R.id.pageControl);
    pageControl.setCount(viewGroup.getChildCount());
    pageControl.generatePageControl(0);
    viewGroup.setScrollToScreenCallback(pageControl);
  }