忍者ブログ

からすまる日誌

202003057pm01 android stadio 画面遷移

×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

202003057pm01 android stadio 画面遷移

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の宣言文がないと
おちるよ
 


ぷりふぁれんす
データの保存
新規
アクティビティ
空のアクティビティ
 
でつくらないと、必要なセットが生成されないよ
 
PR

コメント

ブログ内検索

カレンダー

03 2025/04 05
S M T W T F S
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