forked from hzuapps/android-labs-2018
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hzuapps#4 hzuapps#2201 from Susie-Lau
- Loading branch information
Showing
7 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com1614080901125.androidlabs.hzuapps.edu.hkmacgo; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.View; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
protected TextView textView; | ||
protected Button button ; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
Toolbar toolbar; | ||
toolbar = findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
textView = findViewById(R.id.textview_01); | ||
button = findViewById(R.id.my_button); | ||
|
||
button.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Intent intent = new Intent(MainActivity.this, SecondActivity.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
FloatingActionButton fab; | ||
fab = findViewById(R.id.fab); | ||
fab.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) | ||
.setAction("Action", null).show(); | ||
} | ||
}); | ||
} | ||
|
||
@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_com1614080901116, menu); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
// Handle action bar item clicks here. The action bar will | ||
// automatically handle clicks on the Home/Up button, so long | ||
// as you specify a parent activity in AndroidManifest.xml. | ||
int id = item.getItemId(); | ||
|
||
//noinspection SimplifiableIfStatement | ||
if (id == R.id.action_settings) { | ||
return true; | ||
} | ||
|
||
return super.onOptionsItemSelected(item); | ||
} | ||
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com1614080901125.androidlabs.hzuapps.edu.hkmacgo; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
|
||
public class secondActivity extends AppCompatActivity { | ||
protected Button button ; | ||
protected TextView tes; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_second); | ||
Toolbar toolbar = findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
|
||
FloatingActionButton fab; | ||
fab = findViewById(R.id.fab); | ||
fab.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) | ||
.setAction("Action", null).show(); | ||
} | ||
}); | ||
} | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".activity_main" | ||
tools:layout_editor_absoluteY="100dp"> | ||
|
||
<Button | ||
android:id="@+id/button1" | ||
android:layout_width="200dp" | ||
android:layout_height="60dp" | ||
android:text="½øÈ붩µ¥" | ||
android:textSize="20sp" | ||
tools:layout_editor_absoluteX="100dp" | ||
tools:layout_editor_absoluteY="120dp" /> | ||
|
||
<Button | ||
android:id="@+id/button2" | ||
android:layout_width="200dp" | ||
android:layout_height="60dp" | ||
android:text="È¡Ïû¶©µ¥" | ||
android:textSize="20sp" | ||
tools:layout_editor_absoluteX="100dp" | ||
app:layout_constraintTop_toBottomOf="@+id/button1" | ||
tools:layout_editor_absoluteY="0dp"/> | ||
|
||
<Button | ||
android:id="@+id/button3" | ||
android:layout_width="200dp" | ||
android:layout_height="60dp" | ||
android:text="Í˳ö" | ||
android:textSize="20sp" | ||
tools:layout_editor_absoluteX="100dp" | ||
app:layout_constraintTop_toBottomOf="@+id/button2" | ||
tools:layout_editor_absoluteY="0dp"/> | ||
|
||
|
||
<TextView | ||
android:id="@+id/textView" | ||
android:layout_width="364dp" | ||
android:layout_height="171dp" | ||
android:layout_marginTop="84dp" | ||
|
||
android:textSize="24dp" | ||
app:layout_constraintTop_toBottomOf="@+id/button3" | ||
tools:layout_editor_absoluteX="18dp" /> | ||
|
||
|
||
</android.support.constraint.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com1614080901125.androidlabs.hzuapps.edu.hkmacgo; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
|
||
public class secondActivity extends AppCompatActivity { | ||
protected Button button ; | ||
protected TextView tes; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_second); | ||
Toolbar toolbar = findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
|
||
FloatingActionButton fab; | ||
fab = findViewById(R.id.fab); | ||
fab.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) | ||
.setAction("Action", null).show(); | ||
} | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<resources> | ||
<string name="app_name">My Application</string> | ||
<string name="title_activity_main">MainActivity</string> | ||
<string name="title_home">Home</string> | ||
<string name="title_dashboard">Dashboard</string> | ||
<string name="title_notifications">Notifications</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# 第三次实验 | ||
|
||
## 1.实验目标 | ||
|
||
(1)在界面上显示至少一张图片(按照自己的题目添加); | ||
(2)提交res/drawable及图片使用的代码; | ||
(3)提交res/values, res/layout等其他代码; | ||
(4)将应用运行结果截图,放到实验报告中; | ||
(5)点击图片(或按钮)时,打开另一个Activity。 | ||
|
||
## 2.实验步骤 | ||
|
||
统一步骤: | ||
https://github.com/hzuapps/android-labs-2018/blob/master/labs-steps.md | ||
Android 在TextView 中显示图片的4种方式: | ||
https://blog.csdn.net/u012724237/article/details/79010741 | ||
|
||
## 3.实验结果 | ||
|
||
![image](https://github.com/Susie-Lau/android-labs-2018/blob/master/com1614080901125/%233/res/drawable/cower.png?raw=true) | ||
![image](https://github.com/Susie-Lau/android-labs-2018/blob/master/com1614080901125/%233/res/drawable/cower2.png) | ||
|
||
## 4.实验心得 | ||
此次实验虽然只是考验插入图片,但实际上在进行代码操作的时候,由于对java语言的不熟练,导致花费了很多时间去寻找和修改错误,因此,还是需要好好巩固知识。 |