-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubjectsActivity.java
42 lines (36 loc) · 1.58 KB
/
SubjectsActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.example.workshop;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class SubjectsActivity extends AppCompatActivity {
String[] subjects = { "MATH", "CMPT", "MACM", "STAT"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_subjects);
Spinner spin = (Spinner) findViewById(R.id.subjectSpinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, subjects);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spin.setAdapter(adapter);
}
// Selects subject in spinner and goes to next activity, passing subject selected
public void selectSubject(View v){
Spinner subject = (Spinner)findViewById(R.id.subjectSpinner);
String subj = subject.getSelectedItem().toString();
Log.d("Subject", subj);
Toast.makeText(this, "Selected subject: ", Toast.LENGTH_LONG).show();
Toast.makeText(this, subj, Toast.LENGTH_LONG).show();
Intent i = new Intent(this, CourseActivity.class);
i.putExtra("Subject", subj);
startActivity(i);
}
public void goToSettings(View v){
Intent i = new Intent(this,SettingsActivity.class);
startActivity(i);
}
}