how do i display data i inserted individually in different layout? - android

i have a main page with 2 buttons 'save' & 'search'. when 'save' button is clicked it would open the layout 'DATA' for inserting data such as name, country, city, category, comment. OnClickSave the data would be saved. when the 'search' button is clicked it would open the layout countries.the layout would display data key in countries than selecting from the list it would open the city layout that is save under the country and so on. how do i do so??

I will just write steps here.
Main activity:
On Save button Click : Open a new activity with form. Save the data to database.
On Search button Click: You can open a new activity with listview in it. That listview can contain every country inside database table. On click, you can go to other activity which will fetch the country details, and display them.
If you have any doubt, then please ask.

Related

How to retrieve value from previous activity with click the button using json php?

i'm newbie to android program..I find some error in my final project tour travel app...i want to make listview that contain hotel list, then if listview was clicked will show detail hotel..ok..it works..
On detail hotel page there is a button "CEK KAMAR", it's used to show listview of room hotel based on ID hotel..i got stuck on this part..the listview has showed but all room class of all hotels..i can't filter the listview based on ID hotel..so..i really need help...thanks advance..
For more clear explanation, hereby i enclosed the screenshot app..

Search data from a csv file and put it in a spinner

I'm new at android programming and I need some help..
In my main class I have 2 spinners. One for countries and one for cities. In the first spinner, the user can choose a country. When a country is selected, I would like the second spinner to show the corresponding cities. To do that, I have a .csv file, with countries code (1st column) and cities corresponding (2nd column).
For example, in the first spinner, the user selects CUBA (the corresponding code is CU). Then I want my program to look into my csv file all the lines with "CU" in the first column and take the cities corresponding and print them into the second spinner so that the user can choose a city of Cuba.
My problem is that I don't where I have to put my csv file and how can I program my application to look into it and print my data into the spinner...
Any help would be appreciated.
Thank you
You should create a Service or a Worker Fragment to do all the heavy lifting: open csv, read countries and cities and filter cities given a country. Then create a callback to the Activity showing both spinners to update the UI accordingly. The following components are needed:
1 FragmentActivity to show the spinners. Should have a callback method to receive data updates.
1 Worker Fragment or Service for reading file and broadcasting updates to the FragmentActivity containing the Spinners
Hope it helps.

How to create an editable directory in Android

I want to create a new activity called "Custom Directory". That activity will have a heading called "Directory"
With the following list format:
Name Number
Name Number
Name Number
And at last a button called "Add new.." Where we can add more of such names/numbers.
Also on long pressing any item, a context menu will come called Edit/Delete.
How do I go about doing this? With file writing and stuff, to save the data to sd while the app is inactive?
Take one list view and edittext when you enter data into editext stored into "List"(Whatevere container you use i.e Arraylist.Array) and this "List" container set into adapter
Now give onlongcliklistener your listview item for delete and edit

How to save user inputs and retrieve back in a listview?

I'd like to save the user inputs(string type) in EditText when "Add to favourites" button is clicked. And want to show the saved inputs in a ListView when the user chooses the "Favorites" tab. I have four tabs generally. I want to save the inputs in one tab, not in Favorites tab. How can I do this? I'm using eclipse. Thanks in advance.
Use SharedPreferences to save and retrieve small chunks of data, for big ones consider saving it to a file
Well you can always make an SQLite database and in one tab do the INSERT operation and in favorites tab do the SELECT from the db.
If you don't need that info to be saved in the database, you can make super-global variables, for example.
You can do that by making a new class called 'Constants', for example, and inside declare public static variables.
That way, they can be accessed from anywhere inside your app

How can Dynamic Add and Remove View In android ? And this is also Store even if I closed the Application

In my Application I want to Add and Remove View (like Button, or Textview, Checkbox ) by Coding (Programming ).
In Details:
I have One EditText and One Add Button. User Enter Anything in EditText and Press the Add Button then this one is added in bellow LinearLayout, and whether User click on his/her added Button it will going to next LinearLayout.
I get sucess upto this.
but when user click the button in second LinearLayout then it will come back on first Linearlayout. I am getting error Here, i don't know where I made a Mistake.
And I also facing Problem about how can I Store this all. Like User Add 5 Button and closed the application and whenever he/she came back to application I need whatever he/she previously added.
Here is what i done.
http://dynamicandroidview.blogspot.com/2011/12/how-to-add-view-in-android-by-coding.html
Try to create a database table with minimum 2 columns in your case it will be id and buttonText.
Now when user clicks on the add button it will save text to the database and will create the button dynamically below any buttons which are already created before or as a new button.
Now in your onCreate method get the count of text thats stored in database.Some thing like the following code:
DB getData = DB.getInstance();
getData.open(this);
ArrayList<TextHolder> getList = new ArrayList<TextHolder>();
getList = getData.getAllTextFromGeT();
getData.close();
x = genList.size();
Here x will be the number/count of elements that are already stored in the database.Now you can another int say i and using this i and x in the for loop you can create buttons dynamically.
Inside the loop you can do something like the following to get text for all the buttons that are being created:
TextHolder firstOne = getList.get(i);
String text = firstOne.getText();
You will also need class with getters and setters method in order to convert DB elements into objects.Like in the above code getText() is our getter method which is getting elements from database and returning it here.
here text will be the text of the button.
So every-time users starts the application he will see all the buttons that he created when he ran the application before and newly added button will appear on the spot and also will be stored in the database for future retrieval.
Remember we are just storing text of the button and assigning it unique id which helps us to create the buttons.Hope this helps

Categories

Resources