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
Related
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.
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
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
hi i would like to know solution for such a problem..... i have an xml file containing users data of around 1000 users listed out in alphabetical order. The xml file use to be as follow
<usersdata>
<user>
<id>1</id>
<firstname>A</firstname>
<middlename>AA</middlename>
......
......
</user>
<user>
<id>2</id>
<firstname>B</firstname>
<middlename>BB</middlename>
......
......
</user>
........
........
</usersdata>
Now from the above xml file i am parsing all the tags and storing them in an array list for each tag. I am listing out the Firstname in a listview, by array list of first name. When the any of the list is clicked, it opens up a new activity where the all other details of the selected name is been shown.
For example if third name in the list is clicked, by using its position(example 3), in the next activity i am listing out the third values stored in all the array lists i am using. This is what currently i am doing.
Now the problem is i have a edit box above the list view, named as a search box. If the letter S is typed in it, then all the names starting with S gets listed first. Opening the next activity by clicking the list now gets some wrong data, how to avoid this.
Please give me a suggestion....
For example if the first name C is clicked, it will be listed at position 3
There is a quick and dirty hack: you can store user id in the invisible field, retrieve it on click and use it as an argument for the second activity. I'm afraid I can't come up with better suggestions without seeing the code.
i tried out by setting some flag and by using an example code in developers site. And i am able to list out the data's but this idea does not full fill my apps requirement in the next activity. So i removed the search part in my app.
Sorry for posting such a question here......
I need to create an auto complete text view that will be used in a send email form, the auto complete text view will be loaded with the email contacts of the phone, The user can select from the auto complete drop down list any contact he wants, When he chooses another contact, the value of the auto complete is replaced by the new one, I want the new value to be added to the original one, any one knows what event should i use?
This example demonstrates how to create a class that handles the event given by the spinner when it's changed:
Spinner on value Change
You extend the OnItemSelectedListener class, override onItemSelected() and put your code in there to update the view with the new contact's details.
Then apply your listener to the spinner, perhaps in the onCreate() of your activity:
spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());