标签:
获取当前设备的分辨率
1 DisplayMetrics dm=new DisplayMetrics(); 2 //新建一个分辨对象 3 4 WindowManager wm=this.getWindowManager(); 5 //找到当前显示的窗口 6 7 Display display= wm.getDefaultDisplay(); 8 //根据窗口显示部分,找到屏幕的分辨率 9 display.getMetrics(dm); 10 int width=dm.widthPixels; 11 int height=dm.heightPixels; 12 tx=(TextView)findViewById(R.id.textView1); 13 tx.setText(width+"*"+height); 14
当点击按钮切换layout,
1 class MyEvent implements OnClickListener 2 { 3 int id; 4 MyEvent(){} 5 MyEvent(int id){this.id=id;} 6 @Override 7 public void onClick(View arg0) { 8 // TODO Auto-generated method stub 9 if(id==1){MainActivity.this.setContentView(R.layout.aaa);} 10 if(id==2){MainActivity.this.setContentView(R.layout.bbb);} 11 } 12 }
标签:
原文地址:http://www.cnblogs.com/biyongyao/p/5877704.html