Lesson4
エミュレーターのsetting
このへんを上にドラッグ。
言語設定
設定→システム→言語→日本語を選んで一番上にセット
設定→システム→日付と時刻
時間処理 時間の計算
datepickerがjsにもあれば制作課題にも使えるな
画面遷移
マニフェスト
<activity android:name=".TimeActivity"></activity>
<activity android:name=".MainActivity">
にもどしておく
activity_main
plene textを選ぶとedit textができる
遷移するやつ
MainActivity.java
package com.example.lesson4;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
private TextView myText;
private Button timeButton,preferenceButton,soundButton;
private EditText myEdit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myEdit = findViewById(R.id.myEdit);
timeButton = findViewById(R.id.timeButton);
preferenceButton = findViewById(R.id.preferenceButton);
soundButton = findViewById(R.id.soundButton);
timeButton.setOnClickListener(this);
preferenceButton.setOnClickListener(this);
soundButton.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Intent intent;
if (v != null) {
switch (v.getId()) {
case R.id.timeButton:
intent = new Intent(this, TimeActivity.class);
startActivity(intent);
break;
}
}
}
}
マニフェストに
activityの宣言文がないと
おちるよ
ぷりふぁれんす
データの保存
新規
アクティビティ
空のアクティビティ
でつくらないと、必要なセットが生成されないよ