Get userinput from edittext on a fragment - java

I wanna start out by saying that im just starting to learn android development(and programming) just so you guys know that im not an expert or anything.
So im creating an app that has 5 fragments. the first one has a spinner, the next 3 have each of them 1 edittext, and the last one has a textview. My problem is, i want to collect the user input from the edittext's and the spinner and use it on a formula that is going to give a result to be shown on the last fragment.
And what i need to know is how do i get the user input from the edittexts and the spinner so i can use them on the formula.
For you guys to have an idea of what im aiming for here is a video that i found: http://www.youtube.com/watch?v=gcap7DUgIHg
(I have done other apps that use a basic layout with the edittexts all on one activity, but i wanted to try with the type of layout you see on the video)
I want my app to work exactly like that one, but instead of using numberpickers i use edittexts and a spinner.
This is probably a lot for anyone to explain, but i have been on this forever and i need to deliver this school project tomorrow. Hopefully anyone can give me a help with this as fast as possible.
I appreciate any help given!
Thank you
Here is the code:
MainActivity- http://snipt.org/BGaf2
ResultFragment- http://snipt.org/BGag2
One of the Fragments(Basically all the same)- http://snipt.org/BGah5
PS: SORRY FOR ALL THE COMMENTED CODE AND THE LONG POST, I COULDNT PUT MORE THEN 2 LINKS BECAUSE OF MY REPUTATION
EDIT: Thanks for the reputation! I can now post more than 2 links

Related

Proper way to to show chords and lyrics in Android app using a textview

I have made a simple Kotlin app which is used to see lyrics and chords together.
I made a textview and set it as per requirements, but the problem is that I could not show chords in the lyrics properly.
This is the current status of my app, while this is an example of what I'm trying to achieve.
In the first image, I can edit the content but the ending result is not good.
In the second image, which is taken from another app, the ending result is nice, and every chord is clickable too.
How can I achieve the same in Kotlin or in Java? How can I make it clickable for a single letter within a textview?
How to put chords in proper way?
Please help me.

how do I attach a description to an imagen in android studio?

first of all I want to thank, because in this community I have found a lot of solutions to my development question. But this time I have a big one. I was looking for an answer to it in google and pdf´s and so on. But it's a complicated question and don't know how exactly ask for it in google. I new in app development. so here I go. I'm trying to do an app that shows the different recipes with photos and description like time that it takes and the difficulty and so.
explanation of the question
Apologize because the childish imagen to explain to you but you know (efficiency).
My two questions are:
1) How may I do to attach a description to an image. I mean, I want that the people can add their own recipes and of course I will make a formulary to this, but how may I do to when the people create the recipe that I suppose that it should be an object of a class, the TextView be attached to the bottom of the image automatically. in resume, that the image and the description with their elements be one unique element. I have tried to encapsulate the image and the text view in one layout, but in this case I don't know how to create a new layout once the app is running. ok the user fill the formulary but how to create a new layout on the run. I don't know how to solve this.
2) How may I do to change in the description of the image the quantity of red tomatoes. I mean. if the recipe have 3 in difficulty, 3 of 5, this is settled by the user, but how I do to show 3 red tomatoes of 5 and the other showed in gray?
I know you may say "another Newby" but I have realized that I love programming and in El Salvador (Central America) there´s almost any information about this subject. Again, thanks a lot.
one way to achieve that is by using Recycler view. and every time a user adds an item. you can add it to the list and the system will draw a new item for you.
check this tutorial
let me know if this helps or you need more explanation

Ideas on how to set a button to call a specific position from an ArrayList in a separate activity

Long post ahead...
Ok, I'm not sure how to explain it so I made a couple of screenshots. Also, I want to start off by saying I'm not looking for somebody to write code for me to copy, or links to specific articles. I just need help figuring out if what I want to make is possible and any direction on what to look at. I just haven't done something like that and so far I can't seem to word my searches well enough it seems to be able to find a solution.
TL;DR: I need to get scrn2 to either swipe left and right to prev/next card from the RecyclerView, or add buttons that do that
So. Here's the screenshot. I have already made scrn1 and scrn2, and am looking for a way to get to my mockup (that heart button there is just wishful thinking and I'm not at all concentrating on it, and the buttons on top of the cards are just a left-over from an old test I forgot to remove).
The idea behind this is just sort of a catalogue/text book to help with self-preparation for an exam on a specific topic.
What I have is a RecyclerView that I've populated with CardViews in an ArrayList. Since I'll be having a few cathegories of cards, and each will have around 40-50 in there, this seems like an efficient and quick way to load a long list like that, and it runs smoothly so far so I'm happy with it.
In order to get a "full details" screen (scrn 2) I implemented Parcelable to my single item template/class, and now when I click on a card I get that second activity that shows the full sized image, title and full description text.
I also added a search that filters the cards in real time, since there will be many of them and I want it to be easy to get to a specific item.
So far so good. Everything works, surprisingly.
Where I'm stuck now is that it will be extremely annoying for somebody to keep going in and out of the single items in order to get to the next one, so I need to be able to either make them scroll or have buttons at the bottom that go to previous and next. The thing is, the only time I've used swiping is in a tabbed activity and that requires fragments. When making those I had to have an xml for each tab, and a class to correspond to it, which is definitely not comfortable when I have 40 in 10 categories.
I assume I need something like an onClick event to add for buttons in the activity that holds the information that gets acquired from the RecyclerView to bring a specific position from my ArrayList... Like, if somebody clicks on the third card, the button brings -1 or +1. Or something like that?
Makes some sense in my head, but I can't find a way to search for that, and can't figure out if it's even possible to make. Soo any pointers would be hella useful. I'm really excited about being able to do that much from scratch, but still lack too much knowledge to be able to imagine what would work here. I'm still testing things out and am looking around for information, but will be happy if somebody has input on the situation.

Gather parts from layout, java android

Im pretty new at programming android and this is my problem:
I have a layout page that i have alot of information on, including buttons and textedits. Now i want to split it up in different parts, without having to create different layouts for every headline. So for example, if i choose to see "Information 3" i want to hide everything else on the layout except the "information 3 text/buttons/textedits".
Is it possible to do this? Because i really dont have time for making a new layout for every headline, and i dont want to show every headline at the same time. (I want to keep all information/data in the same layout file)
Maybe there is a smarter way to do it? Thanks in advance!
/Erik
You can call view.setVisibility(View.GONE) if you want to remove it from the layout. you can search some more questions like these:
hide/show on click of Button
how-to-show-hide-grouped-views
Try these and if u need more help then let me know

User-arrangeable Android GridView

So here's the thing, I want to build a GridView containing few items that are movable/rearrangeable by the user. Pretty much similiar as the one you'd see on the home screen of Android.
I've looked into some places but ended up with zero result. The closest thing I was able to find was the sample of a home screen app found on developers.android.com but It doesn't have the thing I'm looking for (the items are unarrangeable).
Please give me a hint how this could be done. Code examples are also welcome.
Thanks in advance! :)
I think you should implement a drag&drop.
The GridView can handle the OnDragListener, so you could do : myGridView.setOnDragListener and do whatever you want with it.
I also advise you to check the following link
I hope it helped!

Categories

Resources