일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- #다차원포인터
- #JAVASCRIPT
- hyperledger transaction
- #2차원배열
- #CallByAddress
- #1차원배열
- html object
- #자바상속#자바이즈어#is~a
- #bubbleSort
- html youtube
- relative path
- #android activity
- #binary
- html multimedia
- html id
- html charset
- mac terminal command
- #C++ has~a
- 토큰경제
- docker example
- #C++ 연산자함수오버로딩
- html code
- html5 new tag
- html plug-in
- border-box
- #성적관리프로그램
- git flow
- #3차원배열
- html video
- 하이퍼레저패브릭
- Today
- Total
A sentimental robot
Activity transition/intent 본문
// activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:background="#aaaaaa"
android:orientation="vertical"
tools:context="com.example.i310_54.myapplication01.MainActivity">
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="next PAGE"
android:onClick="f1"
/>
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name" />
</LinearLayout>
// MainActivity.java
package com.example.i310_54.myapplication01;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.DataSetObserver;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void f1(View view) {
Intent intent=new Intent(getApplicationContext(),AppleActivity.class);EditText editText=findViewById(R.id.editText);
intent.putExtra("eun",editText.getText().toString());
startActivity(intent);
}
}// activity_apple.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:background="#aaaaaa"
android:orientation="horizontal"
tools:context="com.example.i310_54.myapplication01.AppleActivity">
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="previous"
android:onClick="f1"
/>
</LinearLayout>
// AppleActivity.java
package com.example.i310_54.myapplication01;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
public class AppleActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_apple);Button button=findViewById(R.id.button2);
Intent intent=intent.getIntent();
String n=intent.getStringExtra("eun");
button.setText(n);
}
public void f1(View view){
finish();
}
}// AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.i310_54.myapplication01">
<application
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">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".AppleActivity"
android:label="My Application02"
android:theme="@style/AppTheme">
</activity>
</application>
</manifest>
'Android Studio' 카테고리의 다른 글
Transmission (0) | 2018.01.31 |
---|---|
Activity (0) | 2018.01.31 |
ListView (0) | 2018.01.29 |
Spinner (0) | 2018.01.29 |
LinearLayout (0) | 2018.01.12 |