Table Layout creation in Android - android

I'm new to android. I want to retrieve employee details from database and want to display those data into table layout in weekly basis. for that i want to create table layout with fixed header column like employee name, employee id, employee work status on first week,second week,third week,fourth week etc. and dynamic rows means number of employees is unknown.
How to create this?

First of all you have to create Static Headers using Table Layout and than create Dynamic Table Layout inside your Database query which is retrieving your data on weekly basis.
And if you want add First week and Second week Separate header on table than use some trick.
Try this.

Related

Android Sqlite Database Formation

In my application I take entry from user as :-
Name:- -------------------------
Favorite Fruit:- a)
b)
c)
--------- Add More ----------
Then I want to save it into a Sqlite database. Now I provide user to type in edittext search like this:-
Search Fruit:- Apple,Banana
And then I want to query my database and Print the name of those who like atleast Apple and Banana.
Now my issue is how do I make my database columns to achieve results faster.
Should I make two columns Name and FruitsLiked or something else. Because if I make only two colums then how do I search into database.
Thanks
Create one table n two columns. First column is for name , second one comma separated list of fruits.
Then as db query use like keyword based query

Android - Parse Query - need to know if a string is contained within one of multiple columns in my database table

I have an Android application using parse as a backend. One of my tables in my parse database contains groups of users, one row in this table contains 6 columns of users to form one group.
I would like to return each row where the current user is contained in one of the columns.
My question is what is the most optimum way of achieving this?As it stands I can think of two ways:1. query each row in the groups table and loop through each cloumn looking for the current users username.
2. if possible - use a parse query that says if currenUser equals member 1 or member 2 or member 3 or member 4 or member 5 or member 6. But I don't know if this is possible
Any pointers or help would be appreciated?
For your ParseQuery<ParseObject> query object a whereEqualTo method is available query.whereEqualTo(key, value); try using your column name in place or key and your desired value in in place of value.
Using this you will only get the rows which contains your desired values. It just works as the where clause in SQL qyery. so you will not need to iterate over all the DB entries.

Android Expandable Listview have header and child from different table

In one of my app i have database table like
Table 1 :Menu
column
ID,
MenuName,
MeuID
and Table 2 Menuproduct
column
menuId,
menuprice
I need it like
i header of expandble list
menu name
and in child price. like that
how to make it possible? as i have to pass MenuId to get menu price
Please help
Thanks
You need to use join query to get the detail from sqlite database
If you want the details based on MenuID then your query will be like following
SELECT Menu.MenuID, Menu.MenuName, menuprice
FROM Menu
LEFT OUTER JOIN Menuproduct ON Menu.MenuID = Menuproduct.menuId;
http://www.tutorialspoint.com/sqlite/sqlite_using_joins.htm
you need to store the result as custom object in array list.Checkout following
exapandible listview

How to create dynamic database table in SQLite

I am trying to create one application to store information in sq-lite table.
But i want to take table information from user like table name, columns name, and number of columns, also user can edit that by table name, delete column add new column.
how can i do it.
i add example screen for table filed
Android allows you to execute arbitrary SQL strings. Construct a SQL strings from your UI and then input the string into a command similar to db.execute(string).
Reference

Dynamically creating tables in SQLite with user input in Android

I'm quite new to Android and the SQLite. I'm currently working on an app which requires user to create list of their favourite artists.
I have implemented some charts which already display this artist data. I believe I can easily figure out how to implement adding data to lists.
I was thinking of having two separate tables in SQLite :
Lists (which would store the list names which the user has created)
ChartItems (which would store the chart items and the lists they belong to)
However the Lists table only needs one field in this case "ListName" so I thought it might not be crucial to have a table for this.
Is it possible to dynamically create tables when getting input from a user?
For example : A user creates a list and that value is subsequently used to create a table.
Thanks.
You don't want to be creating new tables on the fly. Your proposal for two tables is fine. The list table should have at least two fields - an integer field called id or _id which is the primary key, and a text field for the list name. The Chartitems table will have a field (listid) which holds the id of the list to which it belongs. This means a chartitem can belong to only one list, and adding a chartitem to a list is achieved by setting the listid field in its record. This is a one-to-many relationship.
If you want to have a single chartitem in more than one list, then you need a many-to-many relationship, which is implemented by having a third table (links). This table will have one field mapping to a list (listid), and one field mapping to a chartitem (itemid.) To add a chartitem to a list, you create the appropriate link entry in the links table. In this case the chartitem table does not need the listid field.
I suggest reading up some more on relationships in databases to clarify these concepts. One principle I strongly suggest following is to have every table contain a field called id which is the primary key for that table, and use that for all references from other tables. In the long run this works much better than using other fields (like name) in relationships.

Categories

Resources