Need a help with this app. when I run this app, it is stopped.
Here a source code for Tip calculator application.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#FFF" android:id="@+id/tableLayout" android:stretchColumns="1,2,3" android:padding="5dp"> <!-- tableRow0 --> <TableRow android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/tableRow0"> <TextView android:id="@+id/billTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/billTotal" android:textColor="#000" android:gravity="right" android:paddingRight="5dp"> </TextView> <EditText android:layout_width="wrap_content" android:id="@+id/billEditText" android:layout_height="wrap_content" android:layout_span="3" android:inputType="numberDecimal" android:layout_weight="1"> </EditText> </TableRow> <!-- tableRow1 --> <TableRow android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/tableRow1"> <TextView android:id="@+id/tenTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="10%" android:textColor="#000" android:layout_column="1" android:gravity="center" android:layout_weight="1"> </TextView> <TextView android:id="@+id/fifteenTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="15%" android:textColor="#000" android:gravity="center" android:layout_weight="1"> </TextView> <TextView android:id="@+id/twentyTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="20%" android:textColor="#000" android:gravity="center" android:layout_weight="1"> </TextView> </TableRow> <!-- tableRow2 --> <TableRow android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/tableRow2"> <TextView android:id="@+id/tipTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/tip" android:textColor="#000" android:gravity="right" android:paddingRight="5dp"> </TextView> <EditText android:layout_width="wrap_content" android:id="@+id/tip10EditText" android:layout_height="wrap_content" android:text="@string/zero" android:gravity="center" android:focusable="false" android:layout_weight="1" android:textSize="14sp" android:cursorVisible="false" android:longClickable="false"> </EditText> <EditText android:layout_width="wrap_content" android:id="@+id/tip15EditText" android:layout_height="wrap_content" android:text="@string/zero" android:gravity="center" android:focusable="false" android:layout_weight="1" android:textSize="14sp" android:cursorVisible="false" android:longClickable="false"> </EditText> <EditText android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tip20EditText" android:text="@string/zero" android:gravity="center" android:focusable="false" android:layout_weight="1" android:textSize="14sp" android:cursorVisible="false" android:longClickable="false"> </EditText> </TableRow> <!-- tableRow3 --> <TableRow android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/tableRow3"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/totalTextView" android:text="@string/total" android:textColor="#000" android:gravity="right" android:paddingRight="5dp"> </TextView> <EditText android:layout_width="wrap_content" android:text="@string/zero" android:layout_height="wrap_content" android:id="@+id/total10EditText" android:gravity="center" android:focusable="false" android:layout_weight="1" android:textSize="14sp" android:cursorVisible="false" android:longClickable="false"> </EditText> <EditText android:layout_width="wrap_content" android:text="@string/zero" android:layout_height="wrap_content" android:id="@+id/total15EditText" android:gravity="center" android:focusable="false" android:layout_weight="1" android:textSize="14sp" android:cursorVisible="false" android:longClickable="false"> </EditText> <EditText android:layout_width="wrap_content" android:text="@string/zero" android:layout_height="wrap_content" android:id="@+id/total20EditText" android:gravity="center" android:focusable="false" android:layout_weight="1" android:textSize="14sp" android:cursorVisible="false" android:longClickable="false"> </EditText> </TableRow> <!-- tableRow4 --> <TableRow android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/tableRow4"> <TextView android:id="@+id/customTextView" android:layout_width="wrap_content" android:text="@string/custom" android:textColor="#000" android:paddingRight="5dp" android:gravity="right|center_vertical" android:layout_height="match_parent" android:paddingBottom="5dp" android:focusable="false"> </TextView> <SeekBar android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/customSeekBar" android:layout_span="2" android:progress="18" android:paddingLeft="8dp" android:paddingRight="8dp" android:paddingBottom="5dp" android:layout_weight="1"> </SeekBar> <TextView android:id="@+id/customTipTextView" android:layout_width="wrap_content" android:text="18%" android:textColor="#000" android:gravity="center_vertical" android:layout_height="match_parent" android:paddingLeft="5dp" android:paddingBottom="5dp" android:focusable="false" android:layout_weight="1"> </TextView> </TableRow> <!-- tableRow5 --> <TableRow android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/tableRow5"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/tipCustomTextView" android:text="@string/tip" android:textColor="#000" android:gravity="right" android:paddingRight="5dp"> </TextView> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/tipCustomEditText" android:text="@string/zero" android:gravity="center" android:focusable="false" android:layout_weight="1" android:textSize="14sp" android:cursorVisible="false" android:longClickable="false"> </EditText> <TextView android:id="@+id/totalCustomTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/total" android:textColor="#000" android:gravity="right" android:paddingRight="5dp" android:layout_weight="1"> </TextView> <EditText android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/totalCustomEditText" android:text="@string/zero" android:gravity="center" android:focusable="false" android:layout_weight="1" android:textSize="14sp" android:cursorVisible="false" android:longClickable="false"> </EditText> </TableRow> </TableLayout> </RelativeLayout>
________________________________________________________________________
MainActivity.java
import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.widget.EditText; import android.widget.SeekBar; import android.widget.TextView; import android.widget.SeekBar.OnSeekBarChangeListener; public class MainActivity extends AppCompatActivity { // constants used when saving/restoring state private static final String BILL_TOTAL = "BILL_TOTALL"; private static final String CUSTOM_PERCENT = "CUSTOM_PERCENT"; private double currentBillTotal; private int currentCustomPercent; private EditText tip10EditText; private EditText total10EditText; private EditText tip15EditText; private EditText total15EditText; private EditText billEditText; private EditText tip20EditText; private EditText total20EditText; private TextView customTipTextView; private EditText tipCustomEditText; private EditText totalCustomEditText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // check if app just started or being restored from memory if(savedInstanceState == null) { currentBillTotal = 0.0; // initialize the bill amount to zero currentCustomPercent = 18; // initialize the custom tip to 18% } else { // initialize the custom tip to saved tip percent currentBillTotal = savedInstanceState.getDouble(BILL_TOTAL); // initialize the custom tip to saved tip percent currentCustomPercent = savedInstanceState.getInt(CUSTOM_PERCENT); } // get references to the 10, 15, 20% tip and total EditTexts tip10EditText = (EditText)findViewById(R.id.tip10EditText); total10EditText = (EditText)findViewById(R.id.total10EditText); tip15EditText = (EditText)findViewById(R.id.tip15EditText); total15EditText = (EditText)findViewById(R.id.total15EditText); tip20EditText = (EditText)findViewById(R.id.tip20EditText); total20EditText = (EditText)findViewById(R.id.total20EditText); // get the TextView displaying the custom tip percentage customTipTextView = (TextView)findViewById(R.id.customTipTextView); // get the custom tip and total EditTexts tipCustomEditText = (EditText)findViewById(R.id.tipCustomEditText); totalCustomEditText = (EditText)findViewById(R.id.totalCustomEditText); // get the billEditText billEditText = (EditText)findViewById(R.id.billEditText); // billEditTextWatcher handles billEditText's onTextChanged event billEditText.addTextChangedListener((TextWatcher) billEditText); // the the SeekBar used to set the custom tip amount SeekBar customSeekBar = (SeekBar)findViewById(R.id.customSeekBar); customSeekBar.setOnSeekBarChangeListener((OnSeekBarChangeListener) customSeekBar); } private void updateStandard() { // calculate bill total with a 10% tip double tenPercentTip = currentBillTotal * 0.1; double tenPercentTotal = currentBillTotal + tenPercentTip; // set tipTenEditText's text to tenPercentTip tip10EditText.setText(String.format("%0.02f", tenPercentTip)); // set totalTenEditText's text to tenPercentTotal tip10EditText.setText(String.format("%0.02f", tenPercentTotal)); // calculate bill total with a 15% tip double fifteenPercentTip = currentBillTotal * 0.15; double fifteenPercentTotal = currentBillTotal + fifteenPercentTip; // set tipFifteenEditText's text to 15% tip tip15EditText.setText(String.format("%0.02f", fifteenPercentTip)); // set totalFifteenEditText's text to fifteenPercentTotal tip15EditText.setText(String.format("0.02f", fifteenPercentTotal)); // calculate bill total with a 20% tip double twentyPercentTip = currentBillTotal * 0.2; double twentyPercentTotal = currentBillTotal + twentyPercentTip; // set tipTwentyEditText's text to twentyPercentTip tip20EditText.setText(String.format("%0.02f", twentyPercentTip)); //set totalTwentyEditText's text to twentyPercentTotal total20EditText.setText(String.format("%0.02f", twentyPercentTotal)); } private void updateCustom() { // set customTipTextView's text to match the position of the SeekBar customTipTextView.setText(currentCustomPercent + "%"); // calculate the custom tip amount double customTipAmount = currentBillTotal * currentCustomPercent * 0.01; // calculate the total bill, including the custom tip double customTotalAmount = currentBillTotal + customTipAmount; // display the tip and total bill amounts tipCustomEditText.setText(String.format("0.02f", customTipAmount)); totalCustomEditText.setText(String.format("0.02f", customTotalAmount)); } // save values of billEditText and customSeekBar @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putDouble(BILL_TOTAL, currentBillTotal); outState.putInt(CUSTOM_PERCENT, currentCustomPercent); } private OnSeekBarChangeListener customSeekBarListener = new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // set currentCustomPercent to position of the SeekBar's thumb currentCustomPercent = seekBar.getProgress(); updateCustom(); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }; private TextWatcher billEditTextWatcher = 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) { // convert billEditText's text to a double try { currentBillTotal = Double.parseDouble(s.toString()); } catch (NumberFormatException e) { currentBillTotal = 0.0; // default if an exception occurs } } @Override public void afterTextChanged(Editable s) { } }; }
__________________________________________________________________
string.xml
<resources> <string name="app_name">Tipcalculator</string> <string name = "billTotal">Bill total</string> <string name = "tip">Tip</string> <string name = "total">Total</string> <string name = "custom">Custom</string> <string name = "zero">0.00</string> </resources>
activity_main.xml
<?xml version="1.0"
encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFF"
android:id="@+id/tableLayout"
android:stretchColumns="1,2,3"
android:padding="5dp">
<!-- tableRow0
-->
<TableRow
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/tableRow0">
<TextView
android:id="@+id/billTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/billTotal"
android:textColor="#000"
android:gravity="right"
android:paddingRight="5dp">
</TextView>
<EditText
android:layout_width="wrap_content"
android:id="@+id/billEditText"
android:layout_height="wrap_content"
android:layout_span="3"
android:inputType="numberDecimal"
android:layout_weight="1">
</EditText>
</TableRow>
<!-- tableRow1
-->
<TableRow
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/tableRow1">
<TextView
android:id="@+id/tenTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10%"
android:textColor="#000"
android:layout_column="1"
android:gravity="center"
android:layout_weight="1">
</TextView>
<TextView
android:id="@+id/fifteenTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="15%"
android:textColor="#000"
android:gravity="center"
android:layout_weight="1">
</TextView>
<TextView
android:id="@+id/twentyTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="20%"
android:textColor="#000"
android:gravity="center"
android:layout_weight="1">
</TextView>
</TableRow>
<!-- tableRow2
-->
<TableRow
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/tableRow2">
<TextView
android:id="@+id/tipTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tip"
android:textColor="#000"
android:gravity="right"
android:paddingRight="5dp">
</TextView>
<EditText android:layout_width="wrap_content"
android:id="@+id/tip10EditText"
android:layout_height="wrap_content"
android:text="@string/zero"
android:gravity="center"
android:focusable="false"
android:layout_weight="1"
android:textSize="14sp"
android:cursorVisible="false"
android:longClickable="false">
</EditText>
<EditText android:layout_width="wrap_content"
android:id="@+id/tip15EditText"
android:layout_height="wrap_content"
android:text="@string/zero"
android:gravity="center"
android:focusable="false"
android:layout_weight="1"
android:textSize="14sp"
android:cursorVisible="false"
android:longClickable="false">
</EditText>
<EditText android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/tip20EditText"
android:text="@string/zero"
android:gravity="center"
android:focusable="false"
android:layout_weight="1"
android:textSize="14sp"
android:cursorVisible="false"
android:longClickable="false">
</EditText>
</TableRow>
<!-- tableRow3
-->
<TableRow
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/tableRow3">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/totalTextView"
android:text="@string/total"
android:textColor="#000"
android:gravity="right"
android:paddingRight="5dp">
</TextView>
<EditText android:layout_width="wrap_content"
android:text="@string/zero"
android:layout_height="wrap_content"
android:id="@+id/total10EditText"
android:gravity="center"
android:focusable="false"
android:layout_weight="1"
android:textSize="14sp"
android:cursorVisible="false"
android:longClickable="false">
</EditText>
<EditText android:layout_width="wrap_content"
android:text="@string/zero"
android:layout_height="wrap_content"
android:id="@+id/total15EditText"
android:gravity="center"
android:focusable="false"
android:layout_weight="1"
android:textSize="14sp"
android:cursorVisible="false"
android:longClickable="false">
</EditText>
<EditText
android:layout_width="wrap_content"
android:text="@string/zero"
android:layout_height="wrap_content"
android:id="@+id/total20EditText"
android:gravity="center"
android:focusable="false"
android:layout_weight="1"
android:textSize="14sp"
android:cursorVisible="false"
android:longClickable="false">
</EditText>
</TableRow>
<!-- tableRow4
-->
<TableRow
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/tableRow4">
<TextView
android:id="@+id/customTextView"
android:layout_width="wrap_content"
android:text="@string/custom"
android:textColor="#000"
android:paddingRight="5dp"
android:gravity="right|center_vertical"
android:layout_height="match_parent"
android:paddingBottom="5dp"
android:focusable="false">
</TextView>
<SeekBar
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/customSeekBar"
android:layout_span="2"
android:progress="18"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingBottom="5dp"
android:layout_weight="1">
</SeekBar>
<TextView
android:id="@+id/customTipTextView"
android:layout_width="wrap_content"
android:text="18%"
android:textColor="#000"
android:gravity="center_vertical"
android:layout_height="match_parent"
android:paddingLeft="5dp"
android:paddingBottom="5dp"
android:focusable="false"
android:layout_weight="1">
</TextView>
</TableRow>
<!-- tableRow5
-->
<TableRow
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/tableRow5">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tipCustomTextView"
android:text="@string/tip"
android:textColor="#000"
android:gravity="right"
android:paddingRight="5dp">
</TextView>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tipCustomEditText"
android:text="@string/zero"
android:gravity="center"
android:focusable="false"
android:layout_weight="1"
android:textSize="14sp"
android:cursorVisible="false"
android:longClickable="false">
</EditText>
<TextView
android:id="@+id/totalCustomTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/total"
android:textColor="#000"
android:gravity="right"
android:paddingRight="5dp"
android:layout_weight="1">
</TextView>
<EditText
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/totalCustomEditText"
android:text="@string/zero"
android:gravity="center"
android:focusable="false"
android:layout_weight="1"
android:textSize="14sp"
android:cursorVisible="false"
android:longClickable="false">
</EditText>
</TableRow>
</TableLayout>
</RelativeLayout>
________________________________________________________________________
MainActivity.java
import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.widget.EditText; import android.widget.SeekBar; import android.widget.TextView; import android.widget.SeekBar.OnSeekBarChangeListener; public class MainActivity extends AppCompatActivity { // constants used when saving/restoring state private static final String BILL_TOTAL = "BILL_TOTALL"; private static final String CUSTOM_PERCENT = "CUSTOM_PERCENT"; private double currentBillTotal; private int currentCustomPercent; private EditText tip10EditText; private EditText total10EditText; private EditText tip15EditText; private EditText total15EditText; private EditText billEditText; private EditText tip20EditText; private EditText total20EditText; private TextView customTipTextView; private EditText tipCustomEditText; private EditText totalCustomEditText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // check if app just started or being restored from memory if(savedInstanceState == null) { currentBillTotal = 0.0; // initialize the bill amount to zero currentCustomPercent = 18; // initialize the custom tip to 18% } else { // initialize the custom tip to saved tip percent currentBillTotal = savedInstanceState.getDouble(BILL_TOTAL); // initialize the custom tip to saved tip percent currentCustomPercent = savedInstanceState.getInt(CUSTOM_PERCENT); } // get references to the 10, 15, 20% tip and total EditTexts tip10EditText = (EditText)findViewById(R.id.tip10EditText); total10EditText = (EditText)findViewById(R.id.total10EditText); tip15EditText = (EditText)findViewById(R.id.tip15EditText); total15EditText = (EditText)findViewById(R.id.total15EditText); tip20EditText = (EditText)findViewById(R.id.tip20EditText); total20EditText = (EditText)findViewById(R.id.total20EditText); // get the TextView displaying the custom tip percentage customTipTextView = (TextView)findViewById(R.id.customTipTextView); // get the custom tip and total EditTexts tipCustomEditText = (EditText)findViewById(R.id.tipCustomEditText); totalCustomEditText = (EditText)findViewById(R.id.totalCustomEditText); // get the billEditText billEditText = (EditText)findViewById(R.id.billEditText); // billEditTextWatcher handles billEditText's onTextChanged event // change billEditText.addTextChangedListener(billEditTextWatcher); // the the SeekBar used to set the custom tip amount SeekBar customSeekBar = (SeekBar)findViewById(R.id.customSeekBar); // change customSeekBar.setOnSeekBarChangeListener(customSeekBarListener); } private void updateStandard() { // calculate bill total with a 10% tip double tenPercentTip = currentBillTotal * 0.1; double tenPercentTotal = currentBillTotal + tenPercentTip; // set tipTenEditText's text to tenPercentTip tip10EditText.setText(String.format("%0.02f", tenPercentTip)); // set totalTenEditText's text to tenPercentTotal tip10EditText.setText(String.format("%0.02f", tenPercentTotal)); // calculate bill total with a 15% tip double fifteenPercentTip = currentBillTotal * 0.15; double fifteenPercentTotal = currentBillTotal + fifteenPercentTip; // set tipFifteenEditText's text to 15% tip tip15EditText.setText(String.format("%0.02f", fifteenPercentTip)); // set totalFifteenEditText's text to fifteenPercentTotal tip15EditText.setText(String.format("0.02f", fifteenPercentTotal)); // calculate bill total with a 20% tip double twentyPercentTip = currentBillTotal * 0.2; double twentyPercentTotal = currentBillTotal + twentyPercentTip; // set tipTwentyEditText's text to twentyPercentTip tip20EditText.setText(String.format("%0.02f", twentyPercentTip)); //set totalTwentyEditText's text to twentyPercentTotal total20EditText.setText(String.format("%0.02f", twentyPercentTotal)); } private void updateCustom() { // set customTipTextView's text to match the position of the SeekBar customTipTextView.setText(currentCustomPercent + "%"); // calculate the custom tip amount double customTipAmount = currentBillTotal * currentCustomPercent * 0.01; // calculate the total bill, including the custom tip double customTotalAmount = currentBillTotal + customTipAmount; // display the tip and total bill amounts tipCustomEditText.setText(String.format("0.02f", customTipAmount)); totalCustomEditText.setText(String.format("0.02f", customTotalAmount)); } // save values of billEditText and customSeekBar @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putDouble(BILL_TOTAL, currentBillTotal); outState.putInt(CUSTOM_PERCENT, currentCustomPercent); } private OnSeekBarChangeListener customSeekBarListener = new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // set currentCustomPercent to position of the SeekBar's thumb currentCustomPercent = seekBar.getProgress(); updateCustom(); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }; private TextWatcher billEditTextWatcher = 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) { // convert billEditText's text to a double try { currentBillTotal = Double.parseDouble(s.toString()); } catch (NumberFormatException e) { currentBillTotal = 0.0; // default if an exception occurs } } @Override public void afterTextChanged(Editable s) { } }; }
__________________________________________________________________
string.xml
<resources> <string name="app_name">Tipcalculator</string> <string name = "billTotal">Bill total</string> <string name = "tip">Tip</string> <string name = "total">Total</string> <string name = "custom">Custom</string> <string name = "zero">0.00</string> </resources>
Output:
Need a help with this app. when I run this app, it is stopped. Here a...
Need help to edit the code below. Am using it play a lottery game in Android Studio what i need help with is if play one game u need to clear it up before u could another game. Here is my activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="simpleapps.my.lotteryapplication.MainActivity" android:orientation="vertical" android:layout_margin="10dp" android:weightSum="100"> <TextView android:layout_width="match_parent" android:layout_height="0dp" android:text="Enter White Balls : " android:textColor="#000000" android:textSize="22sp" android:layout_weight="15" /> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:orientation="horizontal" android:weightSum="100" android:layout_margin="10dp" android:layout_weight="15"> <EditText android:id="@+id/wBall1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="20" android:inputType="number"/>...
Need help to edit the code below. Am using it play a lottery game in Android Studio what i need help with is if play one game u need to clear it up before u could another game. Here is my activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="simpleapps.my.lotteryapplication.MainActivity" android:orientation="vertical" android:layout_margin="10dp" android:weightSum="100"> <TextView android:layout_width="match_parent" android:layout_height="0dp" android:text="Enter White Balls : " android:textColor="#000000" android:textSize="22sp" android:layout_weight="15" /> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:orientation="horizontal" android:weightSum="100" android:layout_margin="10dp" android:layout_weight="15"> <EditText android:id="@+id/wBall1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="20" android:inputType="number"/>...
Why is my app crashing? Following is an app that takes notes from users and shows it's encrypted string. It also decrypt and encrypted strings. It saves the note in a file and also loads it back. Please help me identify what I am doing wrong? activity_krypto_note.xml <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".KryptoNoteActivity"> <EditText android:id="@+id/key" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="8dp" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:ems="10" android:hint="Cryptographic Key" android:inputType="number" app:layout_constraintEnd_toStartOf="@+id/encrypt" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <Button android:id="@+id/encrypt" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:onClick="enryptClicked" android:text="ENCRYPT" android:textSize="9sp"...
need help to build a fingerprint app that we have sslserversocket to tell a file use finger print before open the file what have been done below Here is my mainactivity.java and fingerprintHandler.java below <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <TextView android:id="@+id/heading" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginBottom="8dp" android:padding="20dp" android:text="Fingerprint Authentication" android:textAlignment="center" android:textColor="@android:color/black" android:textSize="18sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.0" /> <TextView android:id="@+id/paraMessage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginBottom="8dp" android:text="Place your finger on the fingerprint scanner to...
If anyone here is a Java and Android Studio expert please I really need help fulfilling the requirements needed to make a Rock Paper Scissors game. I mainly need Java code to complete it I will post what I have so far I don't have much time left please if anyone can help me I would really appreciate it. Here's what the app is supposed to do... The player should be able to select either Rock, Paper, or Scissors.The app...
Exercise 11-4 Create a Reminder app In this exercise, you’ll add a service to a Reminder app that displays a notification every hour that says, “Look into the distance. It’s good for your eyes.” Test the app 1. Start Android Studio and open the project named ch11_ex4_Reminder. 2. Review the code. Note that it contains a layout and a class for an activity, but no class for a service. 1. Run the app. Note that it displays a message that...
I need help converting the following two classes into one sql table package Practice.model; import java.util.ArrayList; import java.util.List; import Practice.model.Comment; public class Students { private Integer id; private String name; private String specialties; private String presentation; List<Comment> comment; public Students() {} public Students(Integer id,String name, String specialties, String presentation) { this.id= id; this.name = name; this.specialties = specialties; this.presentation = presentation; this.comment = new ArrayList<Commment>(); } public Students(Integer id,String name, String specialties, String presentation, List<Comment> comment) { this.id= id; this.name...
I need help in getting the second output to show both the commission rate and the earnings for the String method output package CompemsationTypes; public class BasePlusCommissionEmployee extends CommissionEmployee { public void setGrossSales(double grossSales) { super.setGrossSales(grossSales); } public double getGrossSales() { return super.getGrossSales(); } public void setCommissionRate(double commissionRate) { super.setCommissionRate(commissionRate); } public double getCommissionRate() { return super.getCommissionRate(); } public String getFirstName() { return super.getFirstName(); } public String getLastName() { return super.getLastName(); } public String getSocialSecurityNumber() { return super.getSocialSecurityNumber(); } private...
Can you please help me to run this Java program? I have no idea why it is not running. import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.text.DecimalFormat; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; @SuppressWarnings({"unchecked", "rawtypes"}) public class SmartPhonePackages extends JFrame { private static final long serialVersionID= 6548829860028144965L; private static final int windowWidth = 400; private static final int windowHeight = 200; private static final double SalesTax = 1.06; private static JPanel panel;...
Practically dying here with this, need help ASAP, just need to do hide(), hideBoth(), and matchFound(), then implement them, so far in my version i tentatively made them, but I don't know ho to implement them so i posted the original code before i made my version of the three methods listed above. Need help fast, this is ridiculous. Implement just one requirement at a time. For example, try implementing the case where after the user clicks 2 squares, both...