いくつかのアルゴリズムを計算するために文字列を取るアプリがあります。それは正常に動作します。現在、メイン アクティビティからこのアクティビティを呼び出そうとしているため、メイン アクティビティはユーザー入力を取得して、2 番目のアクティビティから文字列を上書きします。メイン アクティビティに編集可能なフィールドがあります。メイン アクティビティから 2 番目のアクティビティに値を渡すことができません。これどうやってするの?メインアクティビティのコードは次のようになります
public void onClick(View view){
switch (view.getid())
case R.id.calculate:
setname= insertname.getText.toString(); //insertname is the Editablefield
Intent i = new Intent(this, themain.class);
i.putExtra("Name",insertname); //
startActivityForresult(i,1);
}
protected void onActivityResult(int requestCode, int resultCode,Intent data) {
super.onactivityresult(requestcode resultcode data);
switch (requestcode ){
case 1:
//return result form activity 2
}
}
// Code for second activity is something like this:
public void onClick(View view) {
switch (view.getid()) {
case R.id.calculate:
break;
/*
* this bit of code takes a string and gets data for this user and
* returns it in an array. I am trying to overwrite this string
*/
}
}