I have 7 EditTexts and I have to multiply each of them together in a formula say a∗b∗c∗d∗e∗f∗g. It is working fine but when one of these EditTexts is empty the formula yields nothing. Now the solution is I have to frame seperate cases of each one of them using if or switch statement. The issue is that there will be 2^7-1=127 such cases or combinations where one of the 7 EditTexts is empty within itself or with other edittexts. So what is the shortest way to resolve this?
Multiplying with Empty Edittexts
112 Views Asked by kaismaqbool hakim At
2
There are 2 best solutions below
2
General Tony
On
You can loop through the number EditText and convert input into numerical values and multiply them together, this will avoid huge number of conditional statements.
val editTexts = arrayOf(editText1, editText2, editText3, editText4, editText5, editText6, editText7)
for (editText in editTexts) {
val input = editText.text.toString().toDoubleOrNull()
if (input != null) {
}
}
Related Questions in ANDROID
- Creating global Class holder
- Flutter + Dart: Editing name of a tab shows up a black screen
- android-pdf-viewer Received status code 401 from server: Unauthorized
- Sdk 34 WRITE_EXTERNAL_STORAGE not working
- ussd reader in Recket Native module
- Incorrect display of LinearGradientBrush in IOS
- The Binary Version Of its metadata is 1.8.0, expected Version is 1.6.0 build error
- I can't make TextInput to auto expand properly in Android
- Creating multiple instances of a class with different initializing values in Flutter
- How to create a lottie animation
- making android analyze with coverity sast tool
- Flutter plugin development android src not opening after opening example
- I initialize my ViewModel in the Activity with several fragments as tabs, but the fragments(tabs) return null for the updated livedata
- Node.js Server + Socket.IO + Android Mobile Applicatoin XHR Polling Error...?
- How I can use the shared preferences class?
Related Questions in IF-STATEMENT
- Basic Python Question: Shortening If Statements
- Why if condition work but else if condition doesn't work?
- How to list several items in the dialog box for execution?
- "if contains" with forbidden special characters
- bash if equals some file
- change binary data like "111 into 001" in python by using if else or using regex
- How much of a bonus do I get if I sell a specific number
- Conditional Concatenation for Exchange Contact Imports
- How can i correct a multiple choice question with multiple correct answers?
- IF AND OR Nested ArrayFormula not working - What am I missing?
- I can search one sheet, but can't manage to string two searches with the IFS function
- How to add 1 (or more generally, perform a simple operation) on a column based on a condition
- Playwright checking the text of a locator and replacing values
- Read a variable and printing it on a monitor - Arduino
- Comparison between two strings is not working
Related Questions in ANDROID-EDITTEXT
- FloatingActionButton doesnt change EditText item in the LIstView
- EditText not taking input in Android?
- How to restrict EditText decimals to two? (Android studio/Kotlin)
- How can I have one recyclerview element using datas from another page?
- how to make an EditText fully visible when opening the soft keyboard
- EditText with maxLines - how to show half of top line
- Android how to create an edittext that look like google login edittext
- Can not type in edittext android due to associated arraylist
- Suggestion text is not displaying in android keyboard
- Bold text is lost in edittext (android app)
- Why Edit text input fill all the other edit texts when navigate to other screen and then come back?
- Android 14 EditText required double click to enter text if hard keyboard is attached
- How to change background color Edittext error box
- Android : How do I know if the adb shell input text is completed?
- Android: outer EditText border stroke
Related Questions in MULTIPLICATION
- RiscV checking if overflow has occurred during multiplication
- Replace last value in each row of a 2d array with the product of all values in the row excluding the last
- How to access specific elements (by index) in Keras?
- Understanding the Output of Vector and Matrix Multiplication in R
- How many additions operation can be performed instead of single multiplication in FPGA?
- Multiply two columns of different dataframes in Python
- Multiplications a*b vs a*0: execution time
- How to combine elements in Karatsuba multiplication
- Multiplying 2 values gives the original value but dividing the same values gives the right answer
- vectorize numpy array multiplication
- Multiplying Two Tables in R
- Intel xmm registers do not load and multiply correctly
- How does the Radix-2 Montgomery multiplication algorithm R2MM work on bit level?
- How to multiple two values of type driver.Value
- Table multiplication in Angular using ngFor
Related Questions in IS-EMPTY
- Trim text by length and insert rows; include empty cells if already exist
- Fetching json data from MongoDB returns an empty array instead of actual data
- What makes an empty object qualify as an Iterable or Array-like object?
- Google Sheets query function returning 0 when queried data returns empty and not treating it as ERROR
- How do I make my terminal quit on an empty cin input in c++?
- Script that split files into parts accidentally creates empty lines at the end PowerShell
- What is std::filesystem::remove_all() supposed to do with an empty path?
- Empty Migration in first Migration in aspcor.net 8
- Why my Monte Carlo estimation of pi plot is empty?
- Power Apps Data Table Empty
- Test if plotly plot is empty
- The problem of configuring the libfptr10 driver in linux (Russian cash register equipment)
- if range in column <> x value condition in google sheets
- excluding Empty cells in powershell
- Getting a pair of numbers sent from one excel sheet to another sheet with gaps in between
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You can solve your problem with a single
ifstatement: