android gridview or listview - android

I'm trying to develop a 3 column gridview and I need advices.
2 columns data coming from database and 3rd column is a delete button.
Data is stored in sqlite and columns like following;
1-Name: name of the product(string)
2-Type(Picture): type picture of the product, there are 10 pictures(type1.gif,type2.gif,...type10.gif)
3-Delete: It is a button or imagebutton which will delete the data from sqlite db.
Can you give a sample project link or tell me which one is better for performance and less code, gridview or listview?

As a suggestion,
you can create a list view, there you need to create a custom layout for the each row. This custom layout consist with textview (product name) , imageview (for the image) and a button. Once you click a certain button , you can get the product name/id from the respective model and delete the corresponding row from the database.
Use view holder patterns for this, and use lazy loader or similar technique to load the rows into the list (if total rows count is much larger).
This would be a the one of easy/efficient way to do this and you can easily find the code from google.

Related

How to insert edittext value from custom listview into sqlite database in android

I am trying to create a VanSale model app in android. I have a form with customer name and customers item field. In the item field I have created a custom listview with 7 columns.Column contains Sl No, ItemCode, ItemName, Quantity,Discount,Rate and Amount. 5 items will shown in the list. When I pressed a add button will add 5 more items to listview. List items can be upto 100. I want to insert the each items in the listview into sqlite database. How can I done this? Is there any other easy methods to done this?
First Think, you have to learn about looping, iteration conceptual in your mind and take a practice using simply array or list data. if You already know about the sqlite database and listview, i thought you only need to made some function to get from listview using position, and another function to write into database.
Second, Listview has position parameter if you passing it into onSelectedItem method, or you can get directly from listview self and get using position, and sqlite db which you use list or array has position also.
I think its a logical question. so my answer is logical too, or you can attach your code's also here to detailing your problem, good luck.

Android - Best way to show data without large amount of layout files

Thanks for all the help recently! Another question!
In the app I'm building, I currently have a layout file with an expandable lstview where you can choose 10 options. When you choose one of those options, you pick another 4 options. From picking the week, you then have 3 more options. Each of those 3 options will currently open a new activity that has a listview with a checkbox and textview in each row, with about 10 rows each.
Instead of making 30 layout files which will probably crash the app(not sure how many it would take to crash the app), I'm thinking there has to be a better way. I have looked it up and can't really find what I'm looking for. I have read a little bit about sqlite, but wouldn't you still need separate layout files to call different parts of the tables? Is there a way to make a single layout file with a list view, and fill the listview with different data from sqlite, depending on where the click came from in the expandable list view?
For example, if they click workout 29 on expandable list view, then click Week 1, then click Day 1.. can that single layout load data from sqlite db. Then if they were to go back and say click workout 30, week 2, day 3, that same layout load different info from the db?
I'm also trying to find out how to make a double expandable list view still
Thanks again!
So this is very simple all you have to do is create a DataAdapter for the listview. You can then add list view items which bind to the onclick listener and then you can clear that list and add new elements to it. a useful link would be.
https://guides.codepath.com/android/Using-an-ArrayAdapter-with-ListView
You should be using a SQLite database for all your data (unless you plan on holding the data in memory which is not a good idea if it is a rather large amount). You should just create a simple view and keep reusing it. What you will have to do is create your own adapter (extending from BaseExpandableListAdapter for Expandable list views and BaseAdapter for normal list views) and then query the SQLite databse table for the data that you need.
If you are only displaying String items, you can directly extend ArrayAdapter and then provide the array of items that you want to display for the normal list.
As far as crashing goes, there are many apps that have well over 30 layout files. Besides even if you did start loading a lot of views, Android will automatically start destroying views as it starts running low on memory and recreate them when it is needed to do so.

Loading Radiobutton from sqlite table

Is it possible to load radiobuttons/radiogroup straight from a sqlite table? That is, the code to generate a radiobutton/radiogroup is loaded from a sqlite column.
I'm attempting to load this information from the database table directly into a ListView. So a user can scroll through a list view and click radio buttons inside each ListView
for that you can create custom listview and in to that handle it's onclick for appropriate outcome.
Useful this link to learn custom list view:
http://www.codelearn.org/android-tutorial/android-listview

Best Approach for displaying web Services Data in android

I have to display web Services Data Either in Tabular form or in Grid form.Where rows and columns of the grid view dynamically increase or decrease.
Every column must have an header.
All the things including header ,images ,no of rows and columns of Grid view can change either product wise or Number of No of item wise.
Means There are No. of product and a Product have No. of Item and its properties.All these thing i have to display either in Grid view or in table view.Where header, images of product or item,and No. of rows and columns can change Dynamically.
What would be the best way to implement this.Does the custom Adapter for displaying the a dynamic table would be helpful.
Please Guide me.New In Stack Over Flow.

Best way to approach Invoice Listing into Multi-Column ArrayList?

I have created a SQLite DB, in this DB is a whole wack of invoices, each invoice has a customer ID or supplier ID depending on if the invoice is a sale or an expense respectively.
Basically, what I am trying to do is query the DB, grab a list of all invoices by whatever customer ID or supplier ID is selected, and display all the invoices for this customer or supplier in a multi-column listview. I have already created the multi-column listview, it is driven by an xml template for each row which is basically a linearlayout with 4 textview's, one for each column.
This being said, there are 4 values from each invoice I would like to populate the listview with. I assume that if I create an ArrayList, add each invoice as it's own row (also an array of the 4 values I need per invoice), I will get a nice and easy multi-dimensional ArrayList that I can simply loop through to populate the listview.
Before I dive into the code, I want to ensure this is the best approach, perhaps there is a method I am missing? I was surprised I couldn't find multi-column listviews, so you never know!
Thanks!
If your ListView is meant to show items from a SQLite DB you want to write a CursorAdapter instead of reading the whole result set into an ArrayList. CursorAdapters can display each row from a query efficiently and help you easily reflect any changes to the backing data that happen while the user is viewing it.
You may also be interested in this Google I/O talk that goes over the basics of ListView: http://www.google.com/events/io/2010/sessions/world-of-listview-android.html

Categories

Resources