Skip to content

Instantly share code, notes, and snippets.

@ziadasem
Last active November 28, 2023 22:41
Show Gist options
  • Save ziadasem/8a2796afbcf682d41f86acddf6a08d78 to your computer and use it in GitHub Desktop.
Save ziadasem/8a2796afbcf682d41f86acddf6a08d78 to your computer and use it in GitHub Desktop.
Basic AppCompatActivity class with two buttons and TextInputLayout
public class JavaActivity extends AppCompatActivity {
Button flutterJavaNavigationButton;
Button kotlinSendingButton ;
TextInputLayout textInputLayout ;
TextView resultTV ;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(this, KotlinActivity.class);
String value = intent.getStringExtra("value");
flutterJavaNavigationButton = findViewById(R.id.flutterJavaNavigationButton);
kotlinSendingButton = findViewById(R.id.kotlinSendingButton);
textInputLayout = findViewById(R.id.inputField);
resultTV = findViewById(R.id.resultTV);
resultTV.setText(value == null? "" : value);
kotlinSendingButton.setOnClickListener(view -> navigateToKotlin());
}
void navigateToKotlin(){
Intent intent = new Intent(this, KotlinActivity.class);
//
intent.putExtra("value", textInputLayout.getEditText().getText().toString() );
startActivity(intent);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment