activity_main.xml


<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout 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=".MainActivity">

<Button

android:id="@+id/btn_next"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="NEXT"/>

<EditText

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="input text"

android:id="@+id/EditText_input"

android:layout_below="@id/btn_next"

</RelativeLayout>


activity_sub.xml


<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout 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=".SubActivity">

<Button

android:id="@+id/btn_prev"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="PREV"/>

<TextView

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/TextView_get"

android:layout_below="@id/btn_prev"

</RelativeLayout>


MainActivity.java


package com.example.intenttext;

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;

public class MainActivity extends AppCompatActivity {

Button btn_next;

EditText EditText_input;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

btn_next = (Button)findViewById(R.id.btn_next);

EditText_input = (EditText)findViewById(R.id.EditText_input);

btn_next.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

Intent intent = new Intent(MainActivity.this, SubActivity.class);

//intent.putExtra("t", EditText_input.getText().toString());

Bundle bundle = new Bundle();

bundle.putString("t2", EditText_input.getText().toString());

intent.putExtras(bundle);

startActivity(intent);

}

});

}

}


SubActivity.java


package com.example.intenttext;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.TextView;

public class SubActivity extends AppCompatActivity {

Button btn_prev;

TextView TextView_get;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_sub);

btn_prev = (Button)findViewById(R.id.btn_prev);

TextView_get = (TextView)findViewById(R.id.TextView_get);

Intent intent = getIntent();

Bundle bundle = intent.getExtras();

String str = bundle.getString("t2");

TextView_get.setText(str);

btn_prev.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

finish();

}

});

}

}


[안드로이드 with 인크레파스] 11강_Intent

https://youtu.be/AdJ05ZPJcpE

 

 

 

 

 

#안드로이드, #스튜디오, #앱, #어플, #만들기, #intent, #bundle, #java, #xml

나의 목표는 안드로이드 앱 만들기이다.

그래서 자바를 공부했다.

유튜브에서 센치한 개발자님의

[센치한 개발자] (9) 자바 기초 강좌 : 클래스, 함수, 객체 (Class, Method, Object)

https://youtu.be/We1zW8fHqXw

 

를 보다가,

나름 똑같이 했는데

안돼는 것이다.!!!

그래서 올린다.

혹시 누구 아시는 분 있으시면, 도와주세요,,,!!!

 


 

package ex01;

public class classmethodobject {

}

public class Taco {

public static void main(String[] args) {

}

public Taco() {

}

public void input(String matter) {

System.out.println(matter + "가 들어간");

}

public void roll(int count) {

System.out.println(count + "번 돌린 타코야키");

}

Taco taco = new Taco();

taco.input("문어");

taco.roll(20);

}

 


 

문어가 들어간

20번 돌린 타코야키

가 출력되어야 한다.

 


 

왜 안돼지???

 

 

 

 

 

 

 

 

 

 

#자바, #java, #안드로이드, #애플, #앱, #어플, #만들기, #센치한개발자, #Taco, #taco, #tacoyaki, #타코

+ Recent posts