I want to create an app for personal use and i'm lost.
It needs to have 9 text inputs and 1 save button.
Saving data to second activity with 9 rows.
1 row for each input text.
Please help.
If understand correctly you want to get user input in one activity and display this input in another activity. Text input is commonly done using an EditText while TextViews are used for showing text. You can put these in your layout XML file and then find them by their resource id. Then you will have to set up a callback for your save Button where you get the input from all of your EditTexts. I assume that you want to go your other activity after that so you can collect the CharSequences into an ArrayList. Then you create an Intent for you other activity and put the ArrayList into your Intent.
You can get the ArrayList again in your other activity via getIntent().getExtras().getCharSequenceArrayListExtra(yourKey) and fill your TextViews with the text from your ArrayList.
Related
In my current Android project, I am adding a layout file for an activity composed by a list of EditText fields and a Button in the end.
I am looking for a way to, when the button is clicked, the method associated to the click retrieve all ths fields and store them in a array of Objects (something like Object object[]).
Anyone knows if this is possible and how to do that?
You have to get a reference to each of the EditTexts and then get their current value, one by one.
I'm building an application to users fill a form. I have 15 questions and I want to divide this questions 5 in each fragment.
The pages are OK and I can fill the fields.
But, on last fragment I want to have a button to save all the data.
Unfortunately, It doesn't work. The onClick function on this button can't access the views from others fragment.
I just want to be capable to save all the form data clicking on a simple button.
Any ideas?
im facing a problem in my project. What im trying to do is,
i need to parse a json reponse to a listview.
While clicking the row i will get some id , and now i need to call another webservice using that id and it should show another list .Suppose i clicked the First row ,ie Board "A". Then the next Listview should be the sublist of A . It might look like the following
A1,A2 etc may or maynot have submenus.
I can get the id of from the clicked row . And if the list is empty means no more submenus.
I dont know how to design this system? Does any one have any idea? Thanks in advance
PS: I will have to make different webservice call to get each submenu that depends on the ID im passing from the listview row click
A few ideas to get you started:
Instead of using ListView, take a look at GridView. ListView does not support more than one column (you have to support that manually) and GridView was introduced for this purpose.
Let's assume your initial list is shown in its own activity. This means you have an activity which queries the webservice on its onCreate() and then displays the results in the ListView/GridView when they are returned asynchronously from the webservice.
It will be convenient to hold the submenu in its own activity. This means you should create another activity for the submenu (maybe it can share code with the first one or even be derived from it to reduce code duplication). This activity will receive in its Intent an argument (take a look at Intent.putExtra and Intent.getExtra) which tells it which row was clicked (it should usually contain the String filter you are about to pass to the webservice). Once this activity is created, in its onCreate it should query the webservice much like the first activity and show its results in its own ListView/GridView.
To connect the two activities you'll need to catch the on click event in the first activity, figure out which row was clicked, and then create an Intent to show the 2nd activity, pass the extra and show it.
This approach will let the user dismiss the 2nd activity using the back key once they're finished with it. Once it's dismissed, the user will be returned to the 1st activity where they can click on a different row.
I am working on a messenger type application,when a user click on a user from chat window I show a blank Layout with a send button and EditText at bottom,now when user type text in Edit Field and click on send I create a dynamic Layout holding some dynamically created other UI component like Label and ImageView etc.now I want to save this UI state when user press back button or home button.I know there is a method for activity like SaveInstance etc it save only data object but here I want to save GUI with data for all chat windows,anyone can guide how I can handle this ?I will be very thankful for guidance. .
You're doing it wrong.
You should be storing your data in some place (in memory, like in a static array somewhere, or in sql if you need to keep it across sessions), and displaying a listView with an adapter on this data. then, when adding data, you only need to notify your adapter to refresh the view.
i want to dispaly text views n other stuff on 1 screen and when ny1 of those is selected i want to go another screen which already has textviews and radiobuttons on it???
how do i do that???
Read more about using Intents and startActivity.
You pass data from one activity with the other using Extras. putString