intent로 받아올때
edittext 를 이용하기때문에
str으로 받아온 intent를 저장하고
이 str을 다시 int형으로 바꾸려고하면 에러가납니다.
왜그럴까요..
// 주석 처리한부분을 살리면 컴파일후에 휴대폰에서 실행시 액티비티전환에서 에러가 납니다.
//주석처리를 하면 액티비티 전환이 됩니다.
뭣때문일까요?
int a=str1 로 저장한후에
배경에서 rgb를 (255,a,b,c) 이런식으로
첫번째 액티비티에서 abc를 받은후에
두번째 액티비티에서는 받은 값의 색상을 나타나게 하려는데 왜이렇게 어렵죠.
a만 먼저 시범적으로 해버려는데 에러 원인을 모르겠습니다.
또한
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().getDecorView().setBackgroundColor(Color.argb(255,0,255,255));
setContentView(R.layout.main2);
이 부분을 가장 아래쪽에 놓았을때 역시 문제가 생기는데 왜그런가요?
package com.example.act_test;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
public class MainActivity2 extends Activity {
// int x;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
Intent intent = getIntent();
String str1;
str1 = intent.getExtras().getString("edittext1");
// int a;
// int x = Integer.valueOf(str1);
TextView Textview1 = (TextView)findViewById(R.id.Textview1);
Textview1.setText(str1+" " );
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().getDecorView().setBackgroundColor(Color.argb(255,0,255,255));
setContentView(R.layout.main2);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
밑에 소스대로 실행하면
package com.example.act_test;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
public class MainActivity2 extends Activity {
// int x;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().getDecorView().setBackgroundColor(Color.argb(255,0,255,255));
setContentView(R.layout.main2);
Intent intent = getIntent();
String str1;
str1 = intent.getExtras().getString("edittext1");
// int a;
// int x = Integer.valueOf(str1);
TextView Textview1 = (TextView)findViewById(R.id.Textview1);
Textview1.setText(str1+" " );
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
두번째 액티비티 실행시
화면은 청록색깔 배경에 edittext문구가 나옵니다.
int형 활용을 어떻게해야될지 도와주세요.
===================================
소스 원본
mainactiviti 2
package com.example.act_test;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
public class MainActivity2 extends Activity {
// int x;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().getDecorView().setBackgroundColor(Color.argb(255,0,255,255));
setContentView(R.layout.main2);
Intent intent = getIntent();
String str1;
str1 = intent.getExtras().getString("edittext1");
// int a;
// int x = Integer.valueOf(str1);
// x=Integer.parseInt(str1);
TextView Textview1 = (TextView)findViewById(R.id.Textview1);
Textview1.setText(str1+" " );
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}