diff --git a/soft1614080902335/java/androidlabs/hzuapps/edu/soft1614080902335/Soft1614080902335Activity1.java b/soft1614080902335/java/androidlabs/hzuapps/edu/soft1614080902335/Soft1614080902335Activity1.java index 1881d0c74..ad27a21cc 100644 --- a/soft1614080902335/java/androidlabs/hzuapps/edu/soft1614080902335/Soft1614080902335Activity1.java +++ b/soft1614080902335/java/androidlabs/hzuapps/edu/soft1614080902335/Soft1614080902335Activity1.java @@ -1,13 +1,33 @@ package androidlabs.hzuapps.edu.soft1614080902335; -import android.support.v7.app.AppCompatActivity; +import android.app.Activity; +import android.content.Intent; import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.view.View.OnClickListener; -public class Soft1614080902335Activity1 extends AppCompatActivity { +import androidlabs.hzuapps.edu.soft1614080902335.R; +import androidlabs.hzuapps.edu.soft1614080902335.Soft1614080902335Activity1; + +public class Soft1614080902335Activity1 extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_soft1614080902335_qq1); + + final Activity thisActivity = this; + final Button btnOpen = (Button) findViewById(R.id.button_open); + btnOpen.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (v.equals(btnOpen)) { + Intent intent = new Intent(thisActivity,Soft1614080902335Activity2.class); + thisActivity.startActivity(intent); + } + } + }); + } } diff --git a/soft1614080902335/report3.md b/soft1614080902335/report3.md new file mode 100644 index 000000000..6b8361bdc --- /dev/null +++ b/soft1614080902335/report3.md @@ -0,0 +1,137 @@ +# 第三次实验 +掌握在Android应用中使用图片等资源的方法。 +## 1. 实验目标 +1 在界面上显示至少一张图片(按照自己的题目添加); +2 提交res/drawable及图片使用的代码; +3 提交res/values, res/layout等其他代码; +4 将应用运行结果截图,放到实验报告中; +5 点击图片(或按钮)时,打开另一个Activity。 +## 2. 实验步骤 + +1 统一步骤: + https://github.com/hzuapps/android-labs-2018/blob/master/labs-steps.md +2 Android 在TextView 中显示图片的4种方式: + https://blog.csdn.net/u012724237/article/details/79010741 + + +## 3. 实验结果 +app运行结果: +![在Android SDK Manager中选择6.0库](https://raw.githubusercontent.com/ChenchenJT/android-labs-2018/master/soft1614080902335/%E5%AE%9E%E9%AA%8C%E4%B8%89%E6%88%AA%E5%9B%BE1.png "配置教育网下载代理") + + +点击按钮后调到另一个Activity: +![在Android SDK Manager中选择6.0库](https://raw.githubusercontent.com/ChenchenJT/android-labs-2018/master/soft1614080902335/%E5%AE%9E%E9%AA%8C%E4%B8%89%E6%88%AA%E5%9B%BE2.png "配置教育网下载代理") + +改变的文件代码: +1 Soft1614080902335Activity1.java +package androidlabs.hzuapps.edu.soft1614080902335; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.view.View.OnClickListener; + +import androidlabs.hzuapps.edu.soft1614080902335.R; +import androidlabs.hzuapps.edu.soft1614080902335.Soft1614080902335Activity1; + +public class Soft1614080902335Activity1 extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_soft1614080902335_qq1); + + final Activity thisActivity = this; + final Button btnOpen = (Button) findViewById(R.id.button_open); + btnOpen.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (v.equals(btnOpen)) { + Intent intent = new Intent(thisActivity,Soft1614080902335Activity2.class); + thisActivity.startActivity(intent); + } + } + }); + + } +} + +2 activity_soft1614080902335_qq1.xml + + + + + + + +