multiple buttons to generate one thing - android

I am new around I am trying to create an app to do several things
1
when I choose the first button it will randomly choose a letter, eg. a the second button will do the same from an another text eg. b and a third button call generate will shuffle the letters and we can have either ab or ba word, that words will generate in a text label.
2
same things but several choose buttons (letters a,b,,d,e,f etc.), maybe 5! generation button again and shuflle letters and generate 5 differents words(abcdef-fbdacf etc.) in differents text labels
I am stuck please help me.
this is a part of my project

Related

How to select a word or multiple words from a sentence in a container and perform an action with the chosen word in flutter

I am trying to select a word or multiple words from a sentence
for eg; Tom had a red hat.
I wanted to choose a hat or red or any of the other words from the sentence and perform an action on the chosen word. I can't seem to understand how i would be able to do that. I have tried it by assigning each word a button. But I wanted to use selectable text for this because I wanted to also choose multiple words of the sentence for example 'red hat' or tom had a''

Is there a performence difference between creating a button programmatically or creating it in xml?

I want to create 16 buttons each have different texts on it.Those text will be picked up randomly from an array depending on another random value.Lets say,
I have 3 words (apple,banana,watermelon), when the activity created it will pick up one of these words.Lets say apple.And in this activity's screen there will be 16 buttons.These buttons must have the letters that apple consists of "a","p","p","l","e" and the remaining buttons will be filled up with other remaining letters of the alphabet.
So in my case what I wonder is should i do the button creation programmatically by taking a value and assigning this value on creation one by one or do it in the xml and leave their text parts and fill up programmatically.
These 2 options in detail :
First : I'm going to create a function which takes a String value as a paramater and returns a button with this text set on it by using setText(); and then locate it in the layout.
Second : I create the layout with those button and leave blank their text parts and in the activity I only assign their letter values.
I vote for the second option but I'd like to know what's your opinion and would there be a difference in terms of performance or memory ?
The disadvantage of declarative approach is that you can get only so
far with XML.
XML is great for look and feel of your user interface, but it does not provide a great way of handling user input. That's where the programmatic approach came.
Everything you can do declarative as well as with programmatically. But java also allows you to specify what happens when the button is actually clicked.
This is the main advantage of programmatic approach to the user interface.
So what is Best ?
Here it is , Both are good at thier point.
1) Use XML , when everything about your user interface is static , such as layout of the screen , all the widget etc.
2) Then switch to the programmatic approach when user interacts with various widget in the user interface.
In other words you would use XML for what the button Looks like and
Java to specify what it does.

Create an array of buttons from a .txt file that can be filtered?

I am working on a project and I've gotten a decent amount of the way through, I just have two questions right now that will put this part of the project to rest. For both of these questions I'll make a note saying that I have a text file called "gameslist.txt" in the assets folder. From what I've seen that is useful information to have when asking a question.
Q1: I want to create an array of Buttons with each button's text being the next line in the text file when the activity is created. So, the first button's text will be the first line in the text file, the second button's text will be the second line of the text file, so on and so forth for each line of the text file. There are 3622 lines of text in the file.
Q2: I have a series of buttons (# - Z). How can I get it so that when the user taps one of the buttons the only lines from the text file starting with that letter (or in # case anything that doesn't start with a letter) are shown?
I hope people can help me with this, and if you can help me with only one of my problems, that's fine. Thank you :)
You'll want an ExpandableListView for this. So you'd ultimately have 3622 items divided into 26 (letters) + 10 (numbers) groups. However, that's still a very large amount of items to load. Search for tutorials on ExpandableListView, the bulk of your working code will be in the ExpandableListAdapter.

Android Application - On Screen Keyboard Input Method

I am trying to build an on screen keyboard, for a simple counter application, that adds some points for 2 diffeent teams in 2 columns.
The design thing is pretty simple, but it seems hard for me to programm the buttons, in order to insert numbers properly.
I have added all the necesery OnClickListeners and used for example this code for number 1
editText1.setText("1");
But, when i try to press the 1 button multiple times, it doesn't type 111 etc. It keeps replacing the last number that was inputed. So if i press 1 and then 2, it just replaces 1 with 2.
Any idea on how this can work please? :D
setText sets the text. It doesn't append the text. If you want to append, use editText1.setText(editText1.getText()+"1");

Best GUI to let the user edit a list of strings in Android?

Suppose, I need the user to be able to input a list of strings somewhere in the settings of the app. Say, it's a list of URLs. The strings are not supposed to have any spaces, commas or semicolons inside.
The easiest thing I thought of so far is to make a big multi-line EditText with a hint to the user "Separate strings by spaces" and each time the user presses OK, use split(" ") to extract the array of strings.
The problem with that simple solution is that sometimes strings are not long enough to fill the whole EditText width, and >1 strings appear visually in 1 line. Sometimes the URLs are too long, so "www." remains on one line, and the rest of the address appears on the next line. It all looks messy and the user looses track where separate URLs start and end in the line.
Another easy solution: a long single-liner where all strings are separated by ; with optional spaces after. VisualStudio uses that in settings, I find it bad as well since you don't see all the strings at once and have to move in this long line a lot (even harder with the clumsy touch screen).
A more expensive solution: a vertically scrollable list of single-line EditTexts, which are generated programmatically each time the settings screen is opened. Would also need a "+" button which creates a new EditText and a "-" button next to each of the existing EditText's.
EDIT: Another idea: show all the strings in a plain ListView with a "+" button in the last row. When you tap "+", it turns into an EditText with 2 buttons to the right: "OK", "Cancel". "OK" would save the newly added string.
If the user taps any of the items in the list, the line turns into an EditText with "OK" and "Delete" button. "OK" saves edits, "Delete" deletes the item. "OK" and "Delete" buttons better should have images instead of words.
Or, well, all strings can be shown in a ListView, and each time the user taps on an item, an additional popup is shown with EditText for editing the string and 3 buttons below: "OK", "Cancel" and "Delete".
Am I thinking along the right lines? Do you know any existing patterns/libraries/solutions which solve this problem efficiently on touch screens?
It would be better, to have only a single editText, where user can set values in list one by one, and can see added values in listView, There may be some provision for a button to save all entered data, onve. See following link once,
http://www.mubasheralam.com/tutorials/android/listview-transcript-mode
IMHO touch screens are not made for extensive writing since the touch keyboards are awful for writing stuff too long or with too much symbols (e.g. programming language or URL). Do not think about touch apps like old desktop apps/systems. Maybe you should rethink your design and try to avoid this data input.
If it's something your app cannot live without, or you simply do want to do it that way anyway:
I think a newline separator is way more clear than a space or a ";" (assuming the URLs cannot contain ";" btw...).
What about one EditText for each URL, generating EditTexts programatically as the previous one is filled.

Categories

Resources