Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
Saving data in a fragment by a button

I have a TextView that stores a specific number of age And there are two buttons, increasing this number and decreasing, after I set a certain number in the textview, how can I save this number in the fragment by the button?

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
       
        View v =  inflater.inflate(R.layout.fragment_third, container, false);
 
 
        TextView age = (TextView) v.findViewById(R.id.age);
        Button button_add_age = (Button) v.findViewById(R.id.button_add_age);
        button_add_age.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Integer.parseInt(age.getText().toString()) > 0) {
                    int age_value = Integer.parseInt(age.getText().toString()) + 1;
                    age.setText(String.valueOf(age_value));
                }
            }
        });
 
        Button button_remove_age = (Button) v.findViewById(R.id.button_remove_age);
        button_remove_age.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Integer.parseInt(age.getText().toString()) > 1) {
                    int age_value = Integer.parseInt(age.getText().toString()) - 1;
                    age.setText(String.valueOf(age_value));
                }
            }
        });

*save button*
Button saveButton = (Button) v.findViewById(R.id.save_button);
         saveButton.setOnClickListener(new View.OnClickListener() {
             @Override 
             public void onClick(View v) {`enter code here`}
         });
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!