Reputation: 11594
from Data Class I get a string and trying to pass it to the OpenedClass but when I click the button nothing actually happens. since Debugger doesnt show the error .I assume my activity doesnt work but I have no clue why ?
here is my Data class
package com.android;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class Data extends Activity implements OnClickListener {
Button start, startFor;
EditText sendET;
TextView gotAnswer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.get);
}
private void initialize() {
start = (Button) findViewById(R.id.bSA);
startFor = (Button) findViewById(R.id.bSAFR);
sendET = (EditText) findViewById(R.id.etSend);
gotAnswer = (TextView) findViewById(R.id.tvGOT);
start.setOnClickListener(this);
startFor.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.bSA:
String bread = sendET.getText().toString();
Bundle basket = new Bundle();
basket.putString("key", bread);
Intent a = new Intent(Data.this, OpenedClass.class);
a.putExtras(basket);
startActivity(a);
break;
case R.id.bSAFR:
break;
}
}
}
and here my code related part of AndroidManifest.xml
<activity
android:name=".Data"
android:exported="false"
android:label="Data" >
</activity>
<activity
android:name=".OpenedClass"
android:exported="false"
android:label="OpenedClass" >
</activity>
Upvotes: 0
Views: 121
Reputation: 132992
you are not calling initialize()
in onCreate
of Activity so call it after setContentView
as:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.get);
initialize() ; //<<< call initialize method here
}
Upvotes: 1