Simple List & List using Database Values - android

i need some suggestions first,
My application is like, on main screen a user clicks the image button "Courses" and navigates to a list, with three items, when user touches any item, he moves into another "List view" that pick up values from the database, and then if a user clicks on any item of second list,will be navigated to final view or a webview..
suggestion i need is, is it a nice practice to navigate a user from list to another list, in a
application..
and in Iphone application they make back button to each view,(as they dont have a back button on iphone) but in many android applications i didn;t seen back button in list view layout, do i need to have a back button on the top of the list view ?
Second question i have is, do i really have to make a Database for a list,
i have to make atleast 6 or 7 Lists in my application, with some list having values nearly 16

Ad. 1: No, you don't need back button in list view. It's real back button in all android devices.
Ad. 2: No. But when data are changing or you want to perform complex queries then database is preferred. In case of not changable data use xml. In case of simple data you can even use shared preferences.
Here is short guide to android data storage:
http://developer.android.com/guide/topics/data/data-storage.html
Here is simple tutorial to use hardcoded data with listview:
http://developer.android.com/resources/tutorials/views/hello-listview.html

I have a few comments on these:
1) The application might end up having a complex navigation to achieve simple tasks if there are multiple levels of lists. Consider using a Tab layout instead of the first level list, since you mentioned there are only 3 entries in the first list. Also try to consolidate your menus so that user can view options upfront
2) Back button: IMHO in android you should only implement it iff you want to override the default behaviour of the back button.
3) Database for a list: Totally depends on whether you want to change the lists once the app is installed. If they are static then you dont need to build it from the database

Related

dynamically create a new activity by pressing of different buttons in different activities

my problem goes like this-
this is a commercial application in which users can purchase different products they see within app..
there is one view cart button available on the main screen
there are 10 different products available in an activity and there are 3 such activities( each of them containing various different products)
these products are arranged in a linear fashion (linear layout).
every product is having an add to cart image button.
what i want is, when the user presses that button, 3 things should happen..
a new activity will be created containing that product information (when the user presses another "add to cart" button, this new product will come below the previous product and so on).
there is one cart button in the menu bar, that cart should show a number equal to the nos of product in the cart.
its simple, a small flash notification that the product has been added to the cart.
any help will be deeply appreciated.
You would see some benefit by using Fragments instead. Use a main Activity as a "switchboard" and multiple Fragment instances to show the per item details.
You don't need to dynamically create a new Activity. Taking into consideration that you call yourself a newbie in android development, I can only tell you what to study to accomplish your plan.
First, learn to make an Activity that will contain a ListView. Make an XML layout for your ListView items, containing TextViews, Buttons, whatever you want. Then, make an adapter that will fill items with corresponding values (texts, button names, images, etc).
And second, make them all clickable (onItemClickListener or an onClickListener for every button) and make your Activity get inflated with a Fragment containing TextViews, ImageViews, etc... whatever you need to represent information about the item selected.
The best practical way is to make an empty Activity with an empty Fragment. The last one will be either inflated (populated) or even replaced with whatever things you need.
Sorry, but teaching you how to make all these things technically is beyond the scope of any sensible answer that someone can post here. It's all the matter of study and practice. But I hope the vector of study I gave you is transparent and affordable.

Android same layout different data

I'm creating a local android application and am trying the following:
The main menu consists of 4 buttons, each will lead to a (different) list of chapters.
The layout of the chapters view is the same, so I am trying to use one layout for every chapters page, by using different strings depending on the button that's being pressed at the main menu. So when the user presses button 1, the list of chapters differs from when the user presses button 2, etc.
I have tried looking up solutions, but was unable to find any so far. Is there a way to call a certain set of strings depending on the button that is chosen?
Have you tried to use a custom list adapter which take your array of strings as a parameter? Your list of chapter is just a simple listview with one string in each row right?

Android Spinner Navigation?

i am currently creating an Android App in which I have data reading from a database. The main part though is that i am using the Spinner widget. As yous know, with an Android Spinner you can have as many options as you like within it.
What i want my Spinner to do is when i select an option, i would like to press a button (a Confirm or 'Ok' button) which will then navigate me to a page, which is related to that button.
For example, I'm doing sports events. So in one of my spinners, i wish it to have a list of events, and when i select a specific event, I want to be directed to a page that has content related to that event
Is this even possible? Or am i better off using a different widget?
You can use a ItemSelectedListener and in the onItemSelected method you can write your navigation code to move to corresponding activity. You can retreive the item details using position parameter in OnIntemSelected method.

How do you organize an application with a list of items, which link to a lot of activities?

I am making an application and I can't figure out what's best to do.
I have a long list of tableRows. About 200 of them. They are different
models of a specific product. Each row, when clicked, should show a
screen with that item's specs for the user to read.
Here are my options, I would need help and guidance on how to do each one of these as I am a beginner (but I'm getting more advanced)
First Approach
Create an activity for each and every item. The user will click the row and then they will have to press back to get back to the list. (I know how to do this. I'm fine with this)
Second Approach
I read about horizontal page swiping. Similar to the Play Store. I would prefer this option, but would I be safer sticking to lots of activities?
When the user clicks a row, it would bring them to the item spec and they will be able to swipe left and right between all the items. Pressing back will bring them back to the list.
(This is the one I need full step-by-step guidance with, so I can learn for the future, thanks)
Does anyone have any other suggestions how I would handle this amount of data?
Thanks
You have a long list of items. That suggests you use a ListActivity to show the items. If the items have similarities, use one view to show them and one Activity to show details. If the items are totally different, use different layouts to inflate in getView and different activities. Having the items in one list suggests, however, that there are similarities and it's best to use one layout in the listview and one activity for details.
Alternatively, you can group your items according to similarity in the way you show them. You may end up with ten different views to use in the listview, and ten different activities.

What is the best way to do multiple listviews in android?

i am writing a software that i have to drill down on content a lot. For example when the program starts a listview is displayed. When user clicks on an item, then a second listview must be displayed. For example:
Select Continent > Select Country > Select State > Select City > Select Address
What is the best way to do this (less memory, faster, easier to code etc)? To create multiple listviews with multiple adapters? Or 1 listview with multiple Adapters? Lists are loaded from an external XML File.
So far i am creating a new adapter and setting it to the listview. How do i create a second listview and after clicking on 1st listview displaying the second one, with animation. Any examples?
Extend my class to ListActivity or Activity?
I would make multiple Activities for this. The first activity to display Continent list, the second the Country list, Third State list, etc...
When the user than click the back button. It will go back to the previous activity (list). Even the scrollstate would be remembered.
This will also add the OS animation between the activities. The code will also be separated and memory freed when closing the list activity.
Sending a value from one activity to another ex CountryCode tot the StateListActivty is done by setting a intent.putExtra("CountryCode", countryCode);
A second approach would be to use a ViewFlipper. Adding each listview as a child. And than setting a custom animation on the show-next and show-previous actions.
Note: Using multiple activities may use abit more memory than the ViewFlipper approach.
I would use separate activities for each list but with only one List Adapter class to be shared by all so you can retain consistency in terms of how the lists look + easy to maintain code. You can use a bundle to pass info from one activity to another.
Another thought: is the info you are referring to part of "settings" info? By that, I mean, is it info the user would put in once into your app, or would they put it in almost everytime they use the app (because each time the info would be different)? If it's an "one-off" type of info, you would be better off using a PreferenceActivity.

Categories

Resources