Android Open Source - roommates Tip Cal Fragment

From Project

Back to project page roommates.


The source code is released under:

Apache License

If you think the Android project roommates listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.mattieapps.roommates;
//  w w  w . j  av a2  s  .  com
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;

 * Created by andrewmattie on 11/28/14.
public class TipCalFragment extends Fragment {

    ImageButton mTipsCalFab;
    TextView mOutputTipsText;
    EditText mGratuityEditText, mCheckPriceEditText;

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        final View fragmentView = inflater.inflate(R.layout.fragment_tipcal, container, false);

        mTipsCalFab = (ImageButton) fragmentView.findViewById(;

        mCheckPriceEditText = (EditText) fragmentView.findViewById(;
        mGratuityEditText = (EditText) fragmentView.findViewById(;

        mOutputTipsText = (TextView) fragmentView.findViewById(;

        mTipsCalFab.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                int price = Integer.parseInt(mCheckPriceEditText.getText().toString());
                int gratuity = Integer.parseInt(mGratuityEditText.getText().toString());
                int output = price * gratuity / 100;

                mOutputTipsText.setText("Tip Amount:\n\n" + Integer.toString(output));


        return fragmentView;

Java Source Code List