Navigation app in Android, populating data - android

I am developing an Android App on which I get a list of events from DB and put them on a ListView. Every item can be clicked to see event details and every detail can be clicked to see statistics on that detail. What is the best approach for populating data? I have an activity that launches a new instance of the same activity to populate the new ListView.
Is it the best thing to do or is it better to do it in another way? I've done something similar in iPhone with the NavigationController and I would like to replicate the navigation forward-backward in Android.
Thanks in advance.

I suggest that you have a look at the NotePad sample, which is similar in what you are trying to do:
It demonstrates how to connect to database
It will teach you how to create a custom url describing your data and how to use this with Intents
It demonstrates switching from a listview to an itemview
It shows how to add/edit/delete items
What it won't show is the statistics view you want for the events. If I were you, I would create a different ListActivity for this and not reuse the main list view.

Related

listfragment android layout

I'm trying to create a layout in my fragment that allows a user to enter their workout. The fragment has an ArrayList of sets, and each set consists of an exercise name, sets/reps, and rest time. I can only populate so many sets at the beginning, and want to add a button at the bottom 'add exercise' in case the user wants more exercises than what the loaded layout allows...example..
Ex #1
sets/reps
rest time
Ex#2
sets/reps
rest time
[add exercise]
I tried using a listfragment and an adapter, but im not sure how I can withdraw the data that is entered into the edit text fields and save them for later use. Any help is greatly appreciated, thanks in advance.
Using adapter is a good idea.
Here is one way to achieve your goal:
When person clicks on add exercise button, you should get the new exercise information from the user. You can use Dialog or another activity-screen for that.
Once you got the info(sets/reps and rest time). Go and update the ArrayList that populates the data in the adapter. And when you done call: Adapter.notifyDataSetChanged() this will make the adapter to invalidate the view based on the changes in the data(ArrayList in your case).

How to create a stack like ListView in Android

I need to create a listview that looks like Stack of list items .
The list should be similar to the one that we see in the Notification Bar or else it should be like most recent Apps in Android L.
Can anyone help me with idea of how to implement such type of list or some sample code fragment.
Use Base Adapter . You can define the element of list anyway you want.
Try using ListView for the UI development and implement the suitable adapter for it.
You need to have three things:
Source of data which you want to display your list view.
Fragment/UI [List View] for displaying the data.
An adapter which binds data to list view.
Check for detailed answer without fragment
Tutorial with fragment and list view

How do you delete an item from a list view in android?

I'm making a basic To-do List app for android and need some help. I need to learn how to delete items from a list view when its tapped on. I know that you record the taps using the OnItemClickListener interface.
It depends on the data and the adepter you're using.
E.g. if it's http://developer.android.com/reference/android/widget/ArrayAdapter.html then you can use Adapter.remove().
If your data is inside a database, you can use your adapter or the your dbhelper.
Please make sure to provide as much information as possible for your problem, so that it's more clear what your problem is exactly.
Btw. great that you're starting early ;-)

Android ListView that opens a subset

I would like to design an item like this that opens a subset of other items when clicked, I have only seen it in other applications I've used, and I can't find any resources on how to create it. Does anyone know how to?
Thanks.
Its not clear if you want to created Nested listviews that look like this
-Item1
-Item2
---Item2A
---Item2B
-Item3
or if you want to open a completely new list when the user clicks on an item.
If you want to use a nested listview look at this question: android nested listview
And if you want to open a new activity, then create a 2nd activity with a listview and open that on an item click
Perhaps you should try to have a look at the ExpandableListView.
Documentation is available from here:
http://developer.android.com/reference/android/widget/ExpandableListView.html
If you wanted to add a ListView that opens another list, you can do it in several ways. I've successfully done it by adding an OnItemClickListener to the ListView and then simply load a new set of data in the ListView and update it using invalidate() or by setting a new Adapter.
You could even add some cool transitions or animations, and create a listener for when the animation is completed. Lots of cool ideas :-)

Showing detail from a ListView

What is the correct way of showing a new View with more detailed information from a ListView in Android? It's a topic that I can't find a solid answer for in either of these Android books.
For example a list of contact names, one is selected and a view shows their full details.
Do I launch a new activity for this or use a ViewFlipper?
Your approach is right. It's the recommended one.
When designing an activity, it's suggested to use this paradigm:
One activity = one thing to do.
Viewing the list
Viewing the details
On the Notepad tutorial app, a new activity is launched to view the details of a list item.
Anyway, the ViewFlipper is another possible approach that keeps all the content in a single activity. This approach is suitable if you manage the Back key correctly.

Categories

Resources