Answer the question
In order to leave comments, you need to log in
How to pass data to another activity in android app?
I need to pass text from EditText to another activity.
I have 2 classes TransitionActivity and CompleteActivity, in 1 I can pass a variable, in the second it does not. Tried a lot of things, but didn't work. What to do?
Transition Activity >
public class TransitionActivity extends AppCompatActivity {
String moneys;
EditText money;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_transition);
EditText money = (EditText)findViewById(R.id.money);
money.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
moneys = money.getText().toString();
complete.setText(moneys);
}
@Override
public void afterTextChanged(Editable s) {
}
});
<EditText
android:inputType="number"
android:textCursorDrawable="@drawable/color_cursor"
android:id="@+id/money"
android:background="@color/white"
android:text="1000"
android:textSize="82px"
android:layout_gravity="center"
android:textAlignment="center"
android:layout_height="match_parent"
android:layout_width="600px"
tools:ignore="RtlCompat" />
Answer the question
In order to leave comments, you need to log in
In a modern android application, there should be one activity. More is possible, but usually not necessary, and you need to clearly understand why. Screens are broken down into fragments.
Data in an activity can be passed inside an Intent.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question