Skip to content
Permalink
Browse files
week 5 starts
  • Loading branch information
Jianhua Yang committed Oct 30, 2017
1 parent 8ab8c0a commit 08a397a145269a6cfcc9788713792d39f6cb628f
Show file tree
Hide file tree
Showing 131 changed files with 731 additions and 89 deletions.
File renamed without changes.
File renamed without changes.
@@ -307,11 +307,11 @@ Refer to Moodle for this. -->
* [Past student coursework No. 1](https://github.com/furgerf/Squash/tree/master/Squash%20Simulation)
* [Past student coursework No. 2](https://github.com/adrianchifor/Swiftnotes)

# T0-DO list
<!-- # T0-DO list
3. Week3, creating old non-generic arraylist example, http://www.javatpoint.com/ArrayList-in-collection-framework
2. Week4, together with Toast, introduce Snackbar, https://developer.android.com/training/snackbar/showing.html
4. Week5, together with listview, introduce RecyclerView, viewholder, TextInputLayout, card view etc., https://developer.android.com/training/material/lists-cards.html
4. Week5, together with listview, introduce RecyclerView, viewholder, TextInputLayout, card view etc., https://developer.android.com/training/material/lists-cards.html -->


# About this Github repository
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.yang.mylists"
minSdkVersion 15
targetSdkVersion 24
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -24,6 +24,7 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
@@ -15,3 +15,11 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
@@ -6,6 +6,7 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
@@ -15,8 +16,6 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".PhotoListActivity" />
<activity android:name=".GridActivity"></activity>
</application>

</manifest>
</manifest>
@@ -1,28 +1,32 @@
package com.example.yang.mylists;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class MainActivity extends AppCompatActivity {
private ListView listView;
private String[] candidateNames;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

candidateNames = getResources().getStringArray(R.array.candidateNames);

listView = (ListView) findViewById(R.id.listViewSimple);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, candidateNames);
listView.setAdapter(arrayAdapter);
listView.setOnItemClickListener(

new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
@@ -31,22 +35,11 @@ public class MainActivity extends AppCompatActivity {
}
);

// List<String> candidateNamesNew = new ArrayList<String>(Arrays.asList(candidateNames));
// ArrayAdapter<String> arrayAdapterNew = new ArrayAdapter<String>(this, android.R.layout
// .simple_list_item_1, candidateNamesNew);
// listView.setAdapter(arrayAdapterNew);
// arrayAdapterNew.add("New Someone");
// arrayAdapter.notifyDataSetInvalidated();
}

public void onButtonClick(View v) {
switch (v.getId()) {
case R.id.complexList:
startActivity(new Intent(this, PhotoListActivity.class));
break;
case R.id.gridView:
startActivity(new Intent(this, GridActivity.class));
break;
}
List<String> candidateNamesNew = new ArrayList<String>(Arrays.asList(candidateNames));
ArrayAdapter<String> arrayAdapterNew = new ArrayAdapter<String>(this, android.R.layout
.simple_list_item_1, candidateNamesNew);
listView.setAdapter(arrayAdapterNew);
arrayAdapterNew.add("New Someone");
arrayAdapter.notifyDataSetInvalidated();
}
}
@@ -1,35 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<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:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.yang.mylists.MainActivity">

<Button
android:id="@+id/complexList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onButtonClick"
android:text="Complex List" />

<Button
android:id="@+id/gridView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/complexList"
android:onClick="onButtonClick"
android:text="Grid View" />

<ListView
android:id="@+id/listViewSimple"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@id/gridView" />
</RelativeLayout>
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -10,6 +10,7 @@
<item>Marco Rubio</item>
<item>Jeb Bush</item>
</string-array>

<string-array name="candidateDetails">
<item>Former US Secretary of State Hillary Clinton (New York)</item>
<item>US Senator Bernie Sanders (Vermont)</item>
@@ -14,4 +14,4 @@ public class ExampleUnitTest {
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
}
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.android.tools.build:gradle:2.3.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -1,6 +1,6 @@
#Mon Dec 28 10:00:20 PST 2015
#Mon Oct 30 14:08:49 GMT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

@@ -0,0 +1 @@
/build

0 comments on commit 08a397a

Please sign in to comment.