Android改变屏幕显示方向.docVIP

  • 2
  • 0
  • 约4.27千字
  • 约 6页
  • 2016-06-12 发布于湖北
  • 举报
AVD SDK Activity_main.xml RelativeLayout xmlns:android=/apk/res/android xmlns:tools=/tools android:layout_width=match_parent android:layout_height=match_parent tools:context=.MainActivity TextView android:id=@+id/myTextViewId android:layout_width=wrap_content android:layout_height=wrap_content android:text=@string/hello_world / Button android:id=@+id/changeButtonId android:layout_width=fill_parent android:layout_height=wrap_content android:layout_below=@id/myTextViewId android:text=改变屏幕方向 / ImageButton android:id=@+id/imageButtonId android:layout_width=fill_parent android:layout_height=wrap_content android:layout_below=@id/changeButtonId android:src=@drawable/mldn_portrait / /RelativeLayout Mainactivity.java package mars.androidtest; import android.os.Bundle; import android.app.Activity; import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.ImageButton; import android.widget.TextView; public class MainActivity extends Activity { private Button button=null; private ImageButton imageButton=null; private TextView textView=null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView=(TextView)findViewById(R.id.myTextViewId); button=(Button)findViewById(R.id.changeButtonId); button.setOnClickListener(new buttonOnClickListener()); imageButton=(ImageButton)findViewById(R.id.imageButtonId); } private class buttonOnClickListener implements OnClickListener{ @Override public void onClick(View arg0) { // TODO Auto-generated method stub if(getRequestedOrientation()==ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED){ textView.setText(错

文档评论(0)

1亿VIP精品文档

相关文档