レシピ本を書いていて、screen1 から情報を送信すると、screen2 が null.null を受信するという問題が発生しました...
これは、recipe_button_list の私のコードです。
public class Recipe_Button_List extends Activity {
TextView inputMethod;
TextView inputIngredients;
@Override
public void onCreate( Bundle savedInstanceState ) {
super.onCreate( savedInstanceState );
setContentView( R.layout.recipe_button_list );
inputMethod = (TextView) findViewById( R.id.textView2 );
inputIngredients = (TextView) findViewById( R.id.textView1 );
//remember when adding more intents to make sure that they are classed as TextView not EditText
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled( true );
Button mainNext = (Button) findViewById( R.id.Recipe1 );
mainNext.setOnClickListener( new OnClickListener() {
public void onClick( View v ) {
final TextView mTextView = (TextView) findViewById( R.id.textView1 );
mTextView.setText( R.string.Test2 );
final TextView mTextView2 = (TextView) findViewById( R.id.textView2 );
mTextView2.setText( R.string.Test );
Intent i = new Intent( getBaseContext(), recipedisplayscreen.class );
//Sending data to the next screen
i.putExtra( "textView1", inputIngredients.getText().toString() );
i.putExtra( "textView2", inputMethod.getText().toString() );
Log.e( "n", inputMethod.getText() + "." + inputIngredients.getText() );
startActivity( i );
}
} );
Button mainNext2 = (Button) findViewById( R.id.Recipe2 );
mainNext2.setOnClickListener( new OnClickListener() {
public void onClick( View v ) {
final TextView mTextView = (TextView) findViewById( R.id.textView1 );
mTextView.setText( R.string.Test );
Intent i = new Intent( getBaseContext(), recipedisplayscreen.class );
//Sending data to the next screen
i.putExtra( "textView1", inputIngredients.getText().toString() );
i.putExtra( "textView2", inputMethod.getText().toString() );
Log.e( "n", inputMethod.getText() + "." + inputIngredients.getText() );
startActivity( i );
}
} );
}
@Override
public boolean onCreateOptionsMenu( Menu menu ) {
MenuInflater inflater = getMenuInflater();
inflater.inflate( R.menu.recipe_menu1, menu );
return true;
}
}
これは私のレシピ_ディスプレイ_スクリーンです:
public class recipedisplayscreen extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.recipedisplayscreen);
TextView MethodDisplay = (TextView) findViewById(R.id.textView3);
TextView IngredientsDisplay = (TextView) findViewById(R.id.textView5);
Intent i = getIntent();
String Ingredients = i.getStringExtra("TextView1");
String Method = i.getStringExtra("TextView2");
Log.e("recipedisplayscreen", Ingredients + "." + Method);
MethodDisplay.setText(Method);
IngredientsDisplay.setText(Ingredients);
ActionBar actionBar = getActionBar();
setTitle(R.string.title);
actionBar.setDisplayHomeAsUpEnabled(true);}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// App icon in action bar clicked; go home
Intent intent = new Intent(this, MainScreen.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.recipe_menu1, menu);
return true;
}
}
任意のアイデア、解決策??? 前もって感謝します :)
PSこれは私のlogcatです:
05-03 18:55:34.734: E/n(21132): if this is displaying then Intent activity is working correctly.bla bla bla working correctly
05-03 18:55:34.883: D/dalvikvm(21132): GC_FOR_ALLOC freed 101K, 2% free 12815K/12999K, paused 23ms
05-03 18:55:34.883: I/dalvikvm-heap(21132): Grow heap (frag case) to 13.885MB for 1401676-byte allocation
05-03 18:55:34.922: D/dalvikvm(21132): GC_CONCURRENT freed 7K, 2% free 14177K/14407K, paused 4ms+2ms
05-03 18:55:34.945: E/recipedisplayscreen(21132): null.null