使用x5cloud云平台来做网络彩讯-------------分辨率问题(五)

许多时候,总会涉及到手机屏幕分辨率问题,所以需要自动获取它:

public class Android_X5_SOSO_4Activity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        find_and_modify_listener();
    }
    
    public void find_and_modify_listener(){
    	Button button1=(Button)findViewById(R.id.button1);
    	button1.setOnClickListener(button1_listener);
    }
    
    public Button.OnClickListener button1_listener=new Button.OnClickListener(){
		@Override
		public void onClick(View v) {	
			onsoClick(v);
		}	
    };
    
	public void onsoClick(View v){
        int id = v.getId();
        switch(id){
        case R.id.button1:
	        DisplayMetrics dm=new DisplayMetrics();
	        getWindowManager().getDefaultDisplay().getMetrics(dm);
	        String str=String.valueOf(dm.widthPixels)+"*"+String.valueOf(dm.heightPixels);
	        TextView tv=(TextView )findViewById(R.id.textview1);
	        tv.setText(str);
        	break;
	    }
    }
}

 

你可能感兴趣的:(x5cloud,android分辨率,网络彩讯)