main2 클래스
int gold = 50000000;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main2);
// TODO Auto-generated method stub
name = (EditText)findViewById(R.id.nametext);
Button b3 = (Button)findViewById(R.id.button1_12);
SharedPreferences pref = getSharedPreferences("money", Activity.MODE_PRIVATE);
SharedPreferences.Editor edit = pref.edit();
edit.putInt("goldbox", gold);
edit.commit();
}
main3 클래스
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main3);
// TODO Auto-generated method stub
intent = getIntent();
name1 =(TextView) findViewById(R.id.main3name);
name2 =(TextView) findViewById(R.id.main3gold);
name1.setText(intent.getStringExtra("INPUT_TEXT").toString());
SharedPreferences pref = getSharedPreferences("money", MODE_PRIVATE);
name2.setText(pref.getInt("goldbox", 0));
안녕하세요 안드로이드 개초짜입니다.
제가 액티비티간에 int값을 전달하고 화면에 출력하는것을 해보려고 합니다 처음에는 putextra 사용해서 하려고했는데
왔다갔다 시키는거 하려면 너무 복잡해지는것 같아서 다른 방법찾아보다가
shardPreferences 쓰면 편하다고 해서 한번 해봤는데요 소스코딩하고난뒤 main3에만 들어가면 오류나오면서 꺼져버리네요
main3에 settext부분이 문제인것같은데 이렇게 쓰는게 아닌건가요?
답답해서 조언을 구해보려고 합니다
name1번은 무시하셔도 됩니다
name2번 settext에서 오류가 나는것같은데 어떻게 해야할까요