0

I want to pass an int from my MainActivity to a RecipeDetails Activity showing it in a TextBox.

I implemented the onClick method from MainActivity passing the value then I tried to get that value in the other Activity setting it in my TextBox. This method works if I try with other strings values from my DB.

    public void onClick(int position) {

    Intent MyEditIntent = new 
    Intent(MainActivity.this,RecipeDetails.class);

    MyEditIntent.putExtra("recipe_target", 
    recipeList.get(position).getTargetPeople());
    startActivity(MyEditIntent);
}
************************************************************
int recipeTarget = getIntent().getIntExtra("recipe_target", 0);
************************************************************
targetView = findViewById(R.id.targetView);
targetView.setText(recipeTarget);
Edoardo Tavilla
  • 523
  • 2
  • 7
  • 18

0 Answers0