intentでputExtra()とgetExtra()を使う方法を教えていただけますか?
ストリングデータを格納するストリング変数があります。activityからactivityにこのデータを送りたいです。
Intent i = new Intent(ScreenA.this, ScreenB.class);
String keyID = null;
i.putExtra(str, keyIDr );
それから、
SecondScreen.java:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.view);
TextView usestr = (TextView)findViewById(R.id.usestr);
Bundle bundle = getIntent().getExtras();
if(bundle.getString("str")!= null)
{
//ストリング変数に格納されたストリングを取得し、
// userNameでsetText()を行います
}
}
基礎的な質問なのですが、お助け願います
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。