how to display table on android with enabled scrolling - android

I'm working on an application for android, where users can upload their csv files.
ofcourse csv files can have lots of rows and/or columns, so my problem is how to display all that data within android table.
i would like to know how to do that and enable scrolling in both horizontal and vertical direction, so the whole table can be viewed?
thanks in advance

If you want to use a table, just put it inside a ScrollView.
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
</TableLayout>
</ScrollView>
Anyway, I don't know if using a table is the best option. I think tables in Android should be deprecated already.

Related

Android auto reduce data table

I am new to Android, and I have a table I made using:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/question_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:orientation="vertical"
android:layout_below="#+id/textView7"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_above="#+id/linearLayout">
</TableLayout>
added rows to it and it perfectly shows the table. Now I want to implement a search box that reduce the result as I type, I am not sure how to do that. I tried searching, maybe I am missing the term to search. Can someone please add a link to it and/or tell me some technique, because re-populating the table everything someone types is like a bad thing to do.
PS: Data is sent from API as JSON, and I own the API.
Displaying large information in TableLayout is bad practice. You can use ListView. Because, every time when text changed in your search box, you need to clear all views in TableLayout, then you need to create rows that appropriate your search filter and then you need to add these rows to TableLayout again. Creating many views and drawing them on screen is hard process for Android and it can crash your app.

Table Layout with dynamic amount of rows and dynamic content

Im pretty new to Android Development, so after like three days of trying different things with the XML Layout Design, i give up and hope for help from you guys.
What i want to achieve:
A table layout with with multiple rows, each filled with calculations im making in the background
The first three rows shall contain the input parameters, the following ~12 rows shall contain output parameters
rows 3 to 6 shall be rearrangeable, so to speak change name and shown values.
This is the concept, thats what one row should look like:
My way of trying things was:
Creating a TableRow for "Taupunkt" and "Td" and another one for three textfields and the +/- picture.
But how on earth am i supposed to insert the ">" arrows picture into the layout? Basically it should be centered between the rows.
I hope i did a clear explanation of my problem and hope that there is someone out there who can help me :)
PS.: App is going to support Android 4.0 and above
EDIT: As seen in the picture, how would i go about centering the plus/minus vertically to the textfields? Like, it should have the same space above and below it to the textfields
You can use ListView or RecyclerView as mentioned in comments.
For second question to make your view centrally aligned you can use android:gravity attribute in LinearLayout. Just made one same which is using center_vertical. Checkout -
<LinearLayout
android:id="#+id/btn_google"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/standard_padding"
android:background="#drawable/rectangle_round_red"
android:gravity="center_vertical"
android:minHeight="#dimen/standard_height"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon_google" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Google"
android:textColor="#android:color/white"
android:textSize="#dimen/font_18" />
</LinearLayout>
This is how it looks

SQLite and MySQL

I'm working on an android application for my final year project. My app is about storing information and then display it out on the phone.
I figure it out by using sqlite, I'm able to store data in it, as well as retrieve it by using cursor c. But how am I able to make the retrieve data visible to the user?
example: I'm creating an app about Burger King, and I click the information about Burger King, it shows the information (when was is created etc) to the user.
This is kind of an open-ended question. If you want to present your search results to the user as a list or a grid, then use a ListView or a Gridview, and attach a CursorAdapter to your View. The CursorAdapter will read the results out of the database and provide them to the View. You'll probably want to subclass your CursorAdapter so that it generates the appropriate views for your ListView/GridView to display.
It's kind of an advanced topic, but I'm sure you can find tutorials and code samples.
If you just want to display a single data item on the screen (presumably a data item with a lot of detail), then you'll probably want to define a Dialog or Activity to present it to the user, and then read the data from the cursor and load it into the various View objects in your Dialog/Activity.
I hope this helps. It would be useful if we knew more detail about what you're trying to do.
I agree with Edward Falk on the need for more clearly defined details. In answering your question I would suggest creating some TextViews or a ListView in your xml file like so:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/fragmentLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp" >
<TextView
android:id="#+id/viewl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/viewvaluesLabel"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/view2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/viewvaluesLabel"
android:textAppearance="?android:attr/textAppearanceLarge" />
.
.
.
</LinearLayout>
</ScrollView>
You can then get these TextViews by their respective ids using a "R.find" statement like:
TextView view1 = (TextView)findViewById(R.id.view1);
TextView view2 = (TextView)findViewById(R.id.view2);
TextView view3 = (TextView)findViewById(R.id.view3);
and then set the data you retrieve from your database table to display in these views using code like this:
Cursor c = db.getDetails(id);
if (c.moveToFirst()) {
view1.setText(c.getString(1));
view2.setText(c.getString(2));
view3.setText(c.getString(3));
} else {
db.close();
}
Hope that helps.

how to display multiple plots(linecharts) in android using achartengine?

i am new to programming and hence android programming.
I'm making an android app in which i have to show eeg data graphically (I mean dynamically in which data is received constantly and the graph is updated constantly with new values added to the right and the graph of old values moving to left and eventually out of view). now I could show 1 plot at a time but it would be really nice if I could show all plots (total 14) on a single screen from top to bottom. Now 14 charts may not be viewable at once, so i could add the function of scrolling so that some charts are visible at a time and others can be seen by scolling up or down.
I am using AChartengine for plotting. Is there some way to display multiple plots on a single screen from top to bottom with scrolling? Thanks for giving ur time.
I guess that, even if you could use a ScrollView to put many charts on same Activity/screen, it would be too heavy and chaotic. Why don't you multiplex data using different dataset for each graph? In this way you could have only some chart to display and data comparaison would be more intuitive...
You can make reference to "average temperature" inside achartengine examples, to know how to put different series (datasets) inside same chart.
Anyway, if you really want to create a 'long' scrolling screen with 14 charts, simply use a ScrollView like this:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="#+id/ScrollViewChartContainer" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:id="#+id/trendchart" android:layout_width="fill_parent" android:layout_height="match_parent" android:background="#android:color/transparent" android:orientation="horizontal" />
<LinearLayout android:id="#+id/trendchart2" android:layout_width="fill_parent" android:layout_height="match_parent" android:background="#android:color/transparent" android:orientation="horizontal" />
...
</ScrollView>
I have not tested such a layout, but it should work.

Android - How to make a vertically-scrollable list

I am new to Android development, and have tried researching my question but can not find a suitable answer.
What I am trying to do is create a list of items, like the numbers 0-9 for example, and display that as a list that the user can scroll up or down to select the desired number, starting at 0.
The best example that I can think of is the HTC Sense timer, linked below (can not post pictures as a new user):
Sense Timer:
What I currently have is a Spinner, but that's not exactly what I want. I want the user to simply swipe up/down to make their selection, not press a button to bring up a drop-down list to make their selection.
Is there a simple way to do this that I am missing, or is it a fairly complicated thing to do? I have not been able to find an example on my own.
Thanks
This is simply known as Wheel View in android. I am not much aware of its implementation, but here is a very good demo. Take a look at it.
http://android-devblog.blogspot.in/2010/05/wheel-ui-contol.html
This will get you started with it.
Here is another one,
http://android-devblog.blogspot.in/2011/01/android-wheel-update-custom-views-for.html
Try ScrollView, may this will work:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
//Your Components
</RelativeLayout>
</ScrollView>
You need to use a listview and an adapter for this. Its a very simple way to implement the vertical scrolling list of items. Please refer the code from the following link:
http://developer.android.com/resources/tutorials/views/hello-listview.html

Categories

Resources