일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- html youtube
- html video
- #자바상속#자바이즈어#is~a
- html5 new tag
- html object
- #C++ 연산자함수오버로딩
- 하이퍼레저패브릭
- mac terminal command
- #성적관리프로그램
- #C++ has~a
- #binary
- git flow
- #1차원배열
- html multimedia
- html charset
- relative path
- html code
- #bubbleSort
- #2차원배열
- docker example
- border-box
- #3차원배열
- html id
- hyperledger transaction
- #android activity
- #CallByAddress
- 토큰경제
- html plug-in
- #다차원포인터
- Today
- Total
A sentimental robot
Transmission 본문
// MainActivity.java
public void f1(View view) {
Intent intent=new Intent(getApplicationContext(),AppleActivity.class);
intent.putExtra("text3",new Tiger(10,"sora")); // 객체 넘기기// 배열 넘기기int ar[]=new int[]{1,2,3,4,5};
intent.putExtra("text4",ar);
String str[]=new String[]{"so","ra"};
intent.putExtra("text5",str);Tiger []ta2=new Tiger[]{
new Tiger(100,"개나리"),
new Tiger(200,"민들레"),
new Tiger(300,"버섯"),
new Tiger(400,"나무")
};
intent.putExtra("text6",ta2);// CollectionArrayList<Integer>li=new ArrayList<>();
li.add(10);
li.add(20);
li.add(30);
li.add(40);
intent.putExtra("text7",li);ArrayList<Tiger>lio=new ArrayList<>();
lio.add(new Tiger(1,"eun"));
lio.add(new Tiger(2,"bi"));
intent.putExtra("text9",lio);
startActivity(intent);
}
}// Tiger.java
package com.example.i310_54.myapplication01;
import java.io.Serializable;
/**
* Created by I310-54 on 2018-01-31.
*/
public class Tiger implements Serializable{
int n;
String s;
public Tiger(int n, String s) {
this.n = n;
this.s = s;
}
public int getN() {
return n;
}
public void setN(int n) {
this.n = n;
}
public String getS() {
return s;
}
public void setS(String s) {
this.s = s;
}
}// AppleActivity.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_apple);
Intent intent=getIntent();
Tiger c=(Tiger)intent.getSerializableExtra("text3");
Log.v("debug",c.getS());int ar[]=intent.getIntArrayExtra("text4");
// int ar[]=(int [])intent.getSerializableExtra("text4"); 가능하다.
for(int a:ar){
Log.v("debug"," "+a);
}String br[]=intent.getStringArrayExtra("text5");
for(String date:br){
Log.v("debug",date);
}Tiger [] e =(Tiger[]) intent.getSerializableExtra("text6");
for(Tiger each:e){
Log.v("debug",each.getS());
}ArrayList<Integer> li=(ArrayList<Integer>) intent.getSerializableExtra("text7");
for(Integer a:li){
Log.v("debug",""+a);
}ArrayList<Tiger>lio=(ArrayList<Tiger>) intent.getSerializableExtra("text9");
for(Tiger ti:lio){
Log.v("debug2",""+ti.getN());
}}
'Android Studio' 카테고리의 다른 글
배경색 자동으로 바꾸기 (0) | 2018.02.01 |
---|---|
TableLayout (0) | 2018.02.01 |
Activity (0) | 2018.01.31 |
Activity transition/intent (0) | 2018.01.30 |
ListView (0) | 2018.01.29 |