20155338 2016-2017-2《Java程序设计》实验四Android程序开发实验报告
2017-05-22 21:44
543 查看
2016-2017-2 20155338 《Java程序设计》实验四Android程序开发实验报告
实验过程及成果展示
1、修改res目录下的layout文件夹中的activity_main.xml布局文件,使得在模拟机上显示出自己的学号信息。
码云链接代码如下:
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.dell1.helloworld.MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="20155312!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> </android.support.constraint.ConstraintLayout>
截图如下:
2、在MainActivity.java中利用Intent类,调用 startActivity方法,使其启动ThirdActivity ,搞清楚ThirdAvtivity是如何利用其它文件设定的“message”显示自己学号的。
码云链接MainActivity.java代码如下:
package com.example.dell1.activitydemo; //import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.widget.TextView; public class MainActivity extends Activity implements OnTouchListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView tv = (TextView) findViewById(R.id.textView1); tv.setOnTouchListener(this); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it // is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onTouch(View arg0, MotionEvent event) { Intent intent = new Intent(this, ThirdActivity.class); intent.putExtra("message", "20155312张竞予"); startActivity(intent); return true; } }
截图如下:
3、导入Toast包,让虚拟机显示默认位置的Toast消息。
码云链接运行截图如下:
4、探索图形化界面,改变其界面方式。
码云链接运行截图如下:
5、AndroidManifest
码云链接.xml文件代码如下:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.dell1.helloworld" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <application android:allowBackup="true" android:label="@string/app_name" android:theme="@style/AppTheme"> <activity android:name="com.example.dell1.helloworld.MainActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
运行截图如下:
相关文章推荐
- # 2016-2017-2 20155319 《Java程序设计》实验四Android程序开发实验报告
- 20155305 2016-2017-2 《Java程序设计》实验四 Android开发基础设计实验报告
- 20155305 2016-2017-2 《Java程序设计》实验四 Android程序开发基础
- 学号20155308 2016-2017-2 《Java程序设计》实验一(Java开发环境的熟悉)实验报告
- 20155227 2016-2017-2 《Java程序设计》实验一 Java开发环境的熟悉(Windws + IDEA)实验报告
- 20145221 《Java程序设计》实验报告四:Android开发基础
- 20155305 2016-2017-2 《Java程序设计》实验一 Java开发环境的熟悉(macOS + IDEA)
- 20155305 2016-2017-2 《Java程序设计》 实验五 Java网络编程及安全实验报告
- 20155307 2016-2017 《Java程序设计》第三次实验报告
- 2016-2017-2 20155312 实验四Android程序设计实验报告
- 20155338 《Java程序设计》实验一(Java开发环境的熟悉)实验报告
- 2016-2017-2 20155329 实验四 Android 开发
- 2016-2017-2 20155338 实验二《Java面向对象程序设计》实验报告
- 20155314 2016-2017-2 《Java程序设计》实验四 Android程序设计
- 20155227 《Java程序设计》实验四 Android开发基础设计实验报告
- 2016-2017-2 20155322 实验四 Android 开发基础
- 20155338 《Java程序设计》实验三(敏捷开发与XP实践)实验报告
- 2016-2017-2 20155339 《Java面向对象程序设计》实验三敏捷开发与XP实践实验报告
- 20155314 2016-2017-2 《Java程序设计》实验三 敏捷开发与XP实践
- 20155332 2016-2017-2 《Java程序设计》实验一 Java开发环境的熟悉