Table view for android - Android Software Development

Hi
I have to implement the table view in my android application. The table view has to display the rows and each row has five labels. When i click on the row it has to display the next screen.
(i want to develop the table view similar iphone UITableView )
Can any body give the sample example link or any other useful document about this table view for android.
Thanks
mindus

Table views are pretty easy to do in an XML layout. You would have something like:
Code:
<TableLayout>
<TableRow>
<TextView>
<TextView>
<TextView>
<TextView>
<TextView>
</TableRow>
<TableRow>
<TextView>
<TextView>
<TextView>
<TextView>
<TextView>
</TableRow>
</TableLayout>
Of course I'm leaving out a lot of the filler, but that would give you 2 rows with 5 columns each. For more information you can go here http://developer.android.com/resources/tutorials/views/hello-tablelayout.html

Hi
Thanks for your reply. I am not looking for xml structure. Basically i want to create a list, and each list row have five text view (horizontally and vertically both) and values of the text view has coming from web service.
Is it possible in list view or i have to use table view only.
Basically What is the difference between list view and table layouts?
Thanks
mindus

ListView is for creating a single up and down list of rows, with each TextView being another row. TableLayout allows you to have columns. You can still get the TableLayout to allow you to scroll up and down by encasing it in a ScrollView.

Related

ThrottleLauncher Skining tutorial

Hi!!!
Here you have a little tutorial on how to create Themes for throttlelauncher. I still have to work on it but almost all is here. With this, theorically you can create almost any interface (still there's some work to do to achieve this ).
Any help, sugestions or requests are appreciated.
To read this tutorial is recomended to know XML file format.
First of all the file structure of a setup for throttlelauncher must be this.
- throttlelauncher instalation
|- Setups
|- MyTheme
|- Skins
|- Skin1
|- skin.xml
|- ...pictures of the skin​ |- Skin2
|- skin.xml
|- ...pictures of the skin​ |- Skin3​ |- config.xml
|- ....imported xml files
|- icons
|- ....my icons... any dir estructure​can be placed inside
To configure the app there are several tags. All the xml must be inside the root tag.
configuration: this tag contains the configuration parameters for the app (especified by the tag param). The allowed params names are:
- appear: Boolean value. Defines if the animation from down to top when the app got focus is activated (only valid for the standalon app).
- skin: defines the path of the folder of the skin to use. Relative to the app folder. See some post's below how to create the skin files.
- speeddecreaserate: factor that multiplies the value of your finger speed when starting kinetic scrolling.
- speedinitmultiply: factor that sets how fast the speed will be decreased in kinetic scrolling. IMPORTANT: set a value greatter than 1.
- status: two possible values. 0: normal (will show title bar and button bar of the app). 1: Maximized (will show the app fullscreen).
- osdenabled: It true, the OSD top bar will be shown when element is selected.
- imagecontactnophoto: Relative path to the image to be used it there's no contact photo.
- minclicktime: Min lapse time in miliseconds between the mouse down and up events to perform a click over the pressed element.
- .... there are some more... I will add them latter.
Example:
Code:
<configuration>
<param name="screenshot" value="True" />
<param name="appear" value="True" />
<param name="skin" value="Setups\Touchflo3D\skins\general" />
<param name="speeddecreaserate" value="1.2" />
<param name="speedinitmultiply" value="1.4" />
<param name="status" value="1" />
</configuration>
page: wich represent a page inside the app. Must be placed inside the root tag and the first one in the file is going to be the first one been showed by default. Page can have 2 attributes:
- name: contains the name of the page. This is going to be used when whe create a link to this page.
- loadonstartup: Boolean value, the default is "true". I recomend to set it to "false" in any page that be do not use frecuently to reduce memory usage.
- autounload: Indicates if the page will be unloaded automatically (and all it's resources will be freed).
- autounloadtime: time a unused page will remain loaded until autounload event starts. This param will be only used it autounload is true.
- import: will import the target xml as content of the page.
Example:
Code:
<page name="Home" loadonstartup="True" autounload="false">
row: Must be placed inside a page tag. They are specified in order from top to bottom. The following attributes are allowed:
- name
- marginX / marginY : margin bettwen the elements contained in the row.
- rows: number of rows of elements. If you set it up to -1 the number of rows is infinite.
- minheight: minimum height of the row (use recomended with dinamically sized rows due to contents like all contactswith photo or runningapps or recent)
- mincolwidth:
- scrollingmode: one of [Paged, WheelOfFortune, Direct, Kinetic, Auto, None]
- alignment: one of [left,right,center]
Example:
Code:
<row name="Programs" marginX="5" marginY="1" rows="3" scrolling="Paged">
footer: Must be placed inside the root tag. It parametters are exactly the same as the row. The footer is common for all the pages. Only one footer can be especified.
icon: Must be used inside the row tag or the footer tag. Used to display an icon. The allowed attributes are:
- name: Will be shown in the OSD when the icon is selected.
- path: path of the icon file. Recomended to use png. Can be absolute or relative to the app path. If the path is not specified, then the file on exec (if it's exe or lnk) will be used to obtain the icon image. No zooming efect will be applied in this case.
- exec: file to execute when the icon is clicked (deprecated, use event click instead).
- params: params for the file execution (deprecated, use event click instead).
- width: override the icons width.
- height: override the icons height.
- rowspan: indicates that the icon fills that number of rows intead of 1.
- showtext: will display the name of the icon as footer text.
Example:
Code:
<icon name="New Contact" exec="\windows\poutlook.exe" params="contacts -new" path="icons\contact.png" />
separator: must be especified inside a row or a footer. Allowed attributes are:
- name: if especified will show a vertical oriented text. If not especified the separator will show a vertical line.
Example:
Code:
<separator name="Personal" />
continues
text: Must be especified inside a row or a footer. Used to show text. Inherits all the atributes of the icon (so background icon can be displayed) plus:
- text: contains the text to be shown. The ~ symbol can be used for "new line", and two especial sentences:
* date: #$date,format#. Will be replaced by the date in the format especified. Will be updated automatically every second.
* reg: #$reg,key#. Will de replaced by the value of the desired key. Will be updated every second. When regkey is especified you can also use this format to parse date registry values: #$reg,key,date,dateformat
Example, start date for next apointment: #$reg,HKEY_CURRENT_USER\System\State\Appointments\Next\Start Time,date,MMM/dd/yyyy hh:mm#
- fonttype: font type specified by "fontname,size,bold" or "size,bold".
- fontcolor: RGB value.
- leftmargin: margin left of the text.
- topmargin: margin top of the text.
- spacing: interline spacing.
- textwidth: defines the width of the area filled by the text
- textheight: defines the height of area filled by the text
- textimages: defines a path where you can place images for each caracter on the text. Example: textimages="setups\Touchflo3d\icons\tf3d\numbers\#$char#.png" where #$char# will be replaced on the path for the character.
Example:
Code:
<text text="#$date,HH:mm:ss#~#$date,dd/MM/yy#~#$date,ddd#" fonttype="12,true" fontcolor="255,255,255" leftmargin="10" topmargin="10" spacing="-10" rowspan="3" width="100"/>
clock: must be inside a row or a footer. Inherits all the attributes of the icon. Can contain the following tags:
- hours
- minutes
- seconds
Each of those tags can contain a color attribute with the color in RGB for the line. If some of those tags is not especified, the respective line will not be shown.
Example:
Code:
<clock name="clock" path="clock.png" rowspan="3">
<hours color="0,0,100"/>
<minutes color="100,100,200"/>
<seconds color="160,160,255"/>
</clock>
allcontactswithphoto: must be inside a row or a footer. Will display all contact with photo matching the criteria in the attributes and assigned to the category "ThrottlePhotoDial".
- name: name of the tag element.
- categoryfilter: comma separated list of contact categories to be included on the filter.
- showcategories: If true will automatically show a separator for each category containing contacts.
- max: max number of contacts to display.
- width/height: define the diaplay size of the contact photos.
- All contacts with photo tag may contain two special icons with this two exec values: ":addcontact",":removecontact". This icons will open a contact selecting dialog allowing to choose a contact to asign or remove the "ThrottlePhotoDialer" category.
Example:
Code:
<allcontactswithphoto height="80" width="60" max="100" showcategories="True" name="Group unnamed">
<icon name="New Contact" exec=":addcontact" rowspan="1" height="80" width="80" path="setups\Default\icons\contact_add.png" />
<icon name="Remove Contact" exec=":removecontact" rowspan="1" height="80" width="80" path="setups\Default\icons\contact_del.png" />
</allcontactswithphoto>
lastapps: must be included inside a row or a footer. Will display the last 12 apps executed (same shown in the start menu). Can include the following attributes:
- name.
- zoom: will zoom the icons if different than 1.
Example:
Code:
<lastapps zoom="1" name="Group unnamed" />
runningapps: will display the running apps icons. The following attributes can be included:
- name.
- zoom: will zoom the icons if different than 1.
Inside you can especify the app's to exclude from the list by using the exclude tag as shown in the example.
Example:
Code:
<runningapps zoom="1" name="Group unnamed">
<exclude name="\Windows\shell32.exe" />
<exclude name="\Windows\cprog.exe" />
<exclude name="\Windows\repllog.exe" />
<exclude name="\Windows\gwes.exe" />
<exclude name="\Windows\filesys.exe" />
<exclude name="\Program Files\ThrottleLauncher\ThrottleLauncher.exe" />
</runningapps>
continued....
folder: this will add an icon for each file cotained in the specified folder matching the pattern if any.
- zoom: zoom to be aplied to the icons.
- path: path of the folder to load. If the folder path is on the registry, you may specify the registry path (sample: HKEY_LOCAL_MACHINE\Explorer\CrossPlatformNavigationURL).
- pattern: pattern to be used to filter the files.
- recursive: indicates wether to look into subfolders (any subfolder loaded will generate automatically a spearator named as the folder).
- name
plugin: this is used to include a today plugin inside the main app (not the today plugin).
- name: name of the plugin to be used. Importan the name MUST be the name of entry in HKEY_LOCAL_MACHINE\Software\Microsoft\Today\Items\. ONLY PLUGINS BASE ON DLL's WILL WORK.
examples:
Code:
<plugin name="ADBWeatherPlus"/>
<plugin name="rlToday"/>
<plugin name="HTC Home"/>
<plugin name="BatteryStatus"/>
-throttleplugin: with this tag you can include 3rd party plugins for throttle launcher. For example you can include flash using the following:
<throttleplugin name="Reloj" path="#$THROTTLE#\Plugins\Flash\FlashPlugin.dll" height="90" class="FlashPlugin.FlashThrottlePlugin">
<param name="movie" value="#$THROTTLE#/Setups/Touchflo3dFlash/TWolf/Clock/horas_28_LITE.swf"/>
<param name="width" value="240"/>
<param name="backgroundpath" value="#$THROTTLE#\Setups\Touchflo3dFlash\TWolf\Clock/fondoReloj.jpg"/>
</throttleplugin>
Skins
Skins are based on xml file as config.xml does. Skin xml file may only contain param tag placed inside the root tag. All the params are optional, so if you don't need one, don't especify it!!
All files refenced by the skin.xml need to be placed on the same skin folder.
Params tag format is the following:
Code:
<param name="name" value="value"/>
The allowed names and it's values meanings are:
- trasparency: will allow trasparency for the skin. This means that if the skin is applied to a row the row background will be filled with the main setup skin texture.
- pagebackcolor: backcolor to be used as page background (only used for main setup skin).
- rowbackcolor: backcolor to be used on the rows (this will be used as the trasparent color if trasparency is specified).
- texture: relative path to the texture image to be used as page background.
- rowtexture: relative path to the texture image to be used as rowbackground.
- buttonback: relative path to the back image to be used on all clickable elements.
- selectionimage: relative path to the hover image to be used when an element is selected.
- buttonbackmargin: margin to be used between the buttonback image and the main element image.
- fontstyle: font style for the text displayed for example in the separators or the contact names. Two formats can be used: "size, bold" or "size, bold, fonttype".
- linecolor: color to be used for lines. Must be specified in an RGB value.
- textcolor: color for text. RGB
- osdtextcolor: color for OSD text. RGB
- osdbackcolor: color to be used as the OSD back color. RGB.
- osdfontstyle: font style for the text displayed in the OSD. Two formats can be used: "size, bold" or "size, bold, fonttype".
reserved.......
reserved.....
Thanks, APBilbo, for sharing this. Really appreciate your help towards the community.
Thanks a lot!!! I really love this app. Its the best one I have found so far. I would be surprised if Verizon and T-mobile dont start using this in the phones they sell...
I wish I had the time to create using ThrottleLauncher, I guess I'll leave it up to the pro's. Thanks for sharing your knowledge.

[Q] ScrollView, SetText and scrollTo

Hi,
Im just getting into Android development and picking up pace slowly. Getting confused how people are getting settings style menus with the appropriate colour Summary Line while adding icons for Stars and Checkboxes etc to highlight and tick.
Anyhoo, I have a TextViews inside a LinearLayout inside a ScrollView, seems to work OK. I use SetText to set the Text on the TextViews and I create everything at run time instead of through the XML files.
But the application I have is a polling type application and I need to repopulate the TextViews and redraw the ScrollView in the same position that the user scrolled to previously.
Im accutely aware of problems using ScrollTo after you've used SetText, so I found the following code:
Code:
sView.post(new Runnable() {
public void run() {
sView.scrollTo(0, iTop);
}
});
It works, but there's a screen flicker where it first draws the screen in its normal position then sets the scrollTo.
What is the best way of achieving this, or am I doing everything completely backwards and most normal people wouldn't have this kind of problem?
Thanks
Simon
It sounds more like you might want to consider using a listview instead. It was designed to contain several child views and scrolls and updates seamlessly.
Hi,
Thanks for the reply. Perhaps I am a bit too much of a beginner.
I seem to be favouring TableLayout so that I can display tabular data and have columns resize correctly and have the data presented OK.
I think that's why I went with updating everything at design time because I have a variable number of rows that can be added. IIUC, variable rows (in an XML file) I think can only be created using ListView, but of course a TableRow needs a TableLayout as a parent.
Here is the idea...
Code:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:id="@+id/TableLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"><TableRow android:id="@+id/TableRow01" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:text="@+id/TextView01" android:paddingRight="5px" android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<TextView android:text="@+id/TextView02" android:id="@+id/TextView02" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
</TableRow>
</TableLayout>
The code I have for TableRows is not dissimilar to, http://en.androidwiki.com/wiki/Dynamically_adding_rows_to_TableLayout
But of course using setText means I cannot then scrollTo
Duh.
First learning curve mastered.
You only need to add views to containers etc the first time you display the screen.
You can update the text in the views later on without affecting the screen position.
I like this.

Loading Framgents up at App Start..

Hey Guys -
This is probably answered somewhere, but for some reason search isn't working at the moment.
So, first, keep in mind that I'm NOT an experienced developer - I have ONE app on the Play Store, and I learned both Java and Android through trial and error and more Google/DuckDuckGo searches than *they* are probably even aware of. When I first released my app, v2.3 or some such was the latest out. :laugh:
So now I'm working on bringing it into the new generation, and playing with fragments.
I've seen two main approaches with them - the first seems to be creating the fragments on the fly in code, as needed. The second seems to be adding them to your main layout (which creates them at app startup).
I decided to go with option #2 - for a couple reasons. (First, it was easier for me to get started by putting them in the XML layout, and because I had some problems trying to get the code to work. Second, one of the fragments uses the Google Maps Fragment, which apparently causes some issues adding/removing the fragments programmatically.(which was causing the errors just mentioned. Third, using the Location service, one of my fragments can read the GPS status from the other, without having to start the service up, wait for a location, and then shut it down.)
And so far, loading the fragments this way seems to work well. Only have one 'glitch' I'm wondering if I'm stuck with, or can work around -
When the app loads, I get the main activity layout, and the screen jumbles all around as the three or four fragments are loaded. Is it possible to somehow hide the messy UI display as fragments are loaded? If I create a splash activity, the fragments don't get loaded until the main activity layout is shown anyways, so that doesn't seem to help the problem any.
Any thoughts are welcome!
-Mike.,
coyttl said:
Hey Guys -
This is probably answered somewhere, but for some reason search isn't working at the moment.
So, first, keep in mind that I'm NOT an experienced developer - I have ONE app on the Play Store, and I learned both Java and Android through trial and error and more Google/DuckDuckGo searches than *they* are probably even aware of. When I first released my app, v2.3 or some such was the latest out. :laugh:
So now I'm working on bringing it into the new generation, and playing with fragments.
I've seen two main approaches with them - the first seems to be creating the fragments on the fly in code, as needed. The second seems to be adding them to your main layout (which creates them at app startup).
I decided to go with option #2 - for a couple reasons. (First, it was easier for me to get started by putting them in the XML layout, and because I had some problems trying to get the code to work. Second, one of the fragments uses the Google Maps Fragment, which apparently causes some issues adding/removing the fragments programmatically.(which was causing the errors just mentioned. Third, using the Location service, one of my fragments can read the GPS status from the other, without having to start the service up, wait for a location, and then shut it down.)
And so far, loading the fragments this way seems to work well. Only have one 'glitch' I'm wondering if I'm stuck with, or can work around -
When the app loads, I get the main activity layout, and the screen jumbles all around as the three or four fragments are loaded. Is it possible to somehow hide the messy UI display as fragments are loaded? If I create a splash activity, the fragments don't get loaded until the main activity layout is shown anyways, so that doesn't seem to help the problem any.
Any thoughts are welcome!
-Mike.,
Click to expand...
Click to collapse
what do you mean with "jumbles "? Loadinganimation? If not, use LoaderManager.LoaderCallbacks
Could you please post your layout file? The one you put the <fragment> tags into.
mynote said:
what do you mean with "jumbles "? Loadinganimation? If not, use LoaderManager.LoaderCallbacks
Click to expand...
Click to collapse
More like you can see each of the fragments load, in order, overlaying each other (especially in cases where I don't specifically set the background, leaving it transaprent, I guess..) In code, then as the first 'fragment' is selected, my code hides the unused one, 'cleaning up' the display. I can't grab a screenshot, since it happens in under half a second.
nikwen said:
Could you please post your layout file? The one you put the <fragment> tags into.
Click to expand...
Click to collapse
Oh, sure -
Code:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:ignore="MergeRootFrame">
<fragment
android:id="@+id/fragment_map"
android:name="com.tsqmadness.bmmaps.views.MapPageFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top" >
<!-- Preview: [email protected]/fragment_mapscreen -->
</fragment>
<fragment
android:id="@+id/fragment_stations"
android:name="com.tsqmadness.bmmaps.views.StationsPageFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top" >
<!-- Preview: [email protected]/fragment_stations -->
</fragment>
<fragment
android:id="@+id/fragment_sheet"
android:name="com.tsqmadness.bmmaps.views.DatasheetPageFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top" >
<!-- Preview: [email protected]/fragment_mapscreen -->
</fragment>
</FrameLayout>
I could go back to creating them all in code, but.. before I do that was wondering if there was anything I overlooked.
Thanks!
-Mike.
coyttl said:
More like you can see each of the fragments load, in order, overlaying each other (especially in cases where I don't specifically set the background, leaving it transaprent, I guess..) In code, then as the first 'fragment' is selected, my code hides the unused one, 'cleaning up' the display. I can't grab a screenshot, since it happens in under half a second.
Oh, sure -
Code:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:ignore="MergeRootFrame">
<fragment
android:id="@+id/fragment_map"
android:name="com.tsqmadness.bmmaps.views.MapPageFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top" >
<!-- Preview: [email protected]/fragment_mapscreen -->
</fragment>
<fragment
android:id="@+id/fragment_stations"
android:name="com.tsqmadness.bmmaps.views.StationsPageFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top" >
<!-- Preview: [email protected]/fragment_stations -->
</fragment>
<fragment
android:id="@+id/fragment_sheet"
android:name="com.tsqmadness.bmmaps.views.DatasheetPageFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top" >
<!-- Preview: [email protected]/fragment_mapscreen -->
</fragment>
</FrameLayout>
I could go back to creating them all in code, but.. before I do that was wondering if there was anything I overlooked.
Thanks!
-Mike.
Click to expand...
Click to collapse
Ah, thanks.
So you want one Fragment being at the front and all others behind it?
Then to hide them all during loading, you could put another View to the top (with android:width and height = "fill_parent"). As soon as all fragments have loaded, you can remove it.
Does that do what you want?
nikwen said:
Ah, thanks.
So you want one Fragment being at the front and all others behind it?
Then to hide them all during loading, you could put another View to the top (with android:width and height = "fill_parent"). As soon as all fragments have loaded, you can remove it.
Does that do what you want?
Click to expand...
Click to collapse
i prefer (this is what i do) replacing it after everything has been loaded. Means, use a framelayout or whatever and just replace it with the fragments, ist not that hard.
i can Show you an example if you want to
nikwen said:
Ah, thanks.
So you want one Fragment being at the front and all others behind it?
Then to hide them all during loading, you could put another View to the top (with android:width and height = "fill_parent"). As soon as all fragments have loaded, you can remove it.
Does that do what you want?
Click to expand...
Click to collapse
I'll give that a try! Essentially, I just want to hide all the apparent 'loading' of widgets until everything IS loaded, to clean up the launch process. (Obviously, this action does NOT happen if the app is in the background and brought forward - only on fresh launches - i.e. After being killed, or phone reboot.)
I hadn't thought of creating a fourth view in front of everything to hide them - I will try that. I don't see why it wouldn't work. I'll let you know tomorrow!
mynote said:
i prefer (this is what i do) replacing it after everything has been loaded. Means, use a framelayout or whatever and just replace it with the fragments, ist not that hard.
i can Show you an example if you want to
Click to expand...
Click to collapse
I wouldn't mind seeing some code, either. (Since I 'taught myself', I really do enjoy seeing other ways - usually better and quicker - at doing things. :laugh
Thanks guys -
Mike.
http://www.vogella.com/articles/AndroidFragments/article.html
scroll down, there is an example how to replace placeholder with fragments. you can receive broadcasts when the Fragment is done and replace it then this way
---------- Post added at 09:44 PM ---------- Previous post was at 09:43 PM ----------
http://www.vogella.com/articles/AndroidFragments/article.html
scroll down, there is an example how to replace placeholder with fragments. you can receive broadcasts when the Fragment is done and replace it then this way
mynote said:
http://www.vogella.com/articles/AndroidFragments/article.html
scroll down, there is an example how to replace placeholder with fragments. you can receive broadcasts when the Fragment is done and replace it then this way
---------- Post added at 09:44 PM ---------- Previous post was at 09:43 PM ----------
http://www.vogella.com/articles/AndroidFragments/article.html
scroll down, there is an example how to replace placeholder with fragments. you can receive broadcasts when the Fragment is done and replace it then this way
Click to expand...
Click to collapse
I just saw these exercises: http://www.vogella.com/articles/AndroidFragments/article.html#tutorial_dyanmicfragments
Did I miss anything?
nikwen said:
I just saw these exercises: http://www.vogella.com/articles/AndroidFragments/article.html#tutorial_dyanmicfragments
Did I miss anything?
Click to expand...
Click to collapse
No. That's true. You just have to use some way to get informed when the cursorloader is finished.
This should be that hard. Use a "Harcoded" Loading layout instead of Fragment and as soon as you get a notify (broadcastreceiver, fragmentmanager, whatever) then you "visible" replace the Fragment
mynote said:
No. That's true. You just have to use some way to get informed when the cursorloader is finished.
This should be that hard. Use a "Harcoded" Loading layout instead of Fragment and as soon as you get a notify (broadcastreceiver, fragmentmanager, whatever) then you "visible" replace the Fragment
Click to expand...
Click to collapse
If I ever need this, I'll be able to do that. Just wondering where the code was. :laugh:
Okay, so you guys lost me going back and forth in the last few messages there. (Not your fault, again, remember, I taught myself and am slow. )
However, an update on some things I tried:
Adding a view to overlay the other fragments does NOT work, unfortunately:
If added in the layout before the fragments, the view is created first, but then is underneath the fragments, defeating the purpose, because of Z-Order.
If the layout view is AFTER the fragments, it's now on top of the other fragments, BUT, because the other fragments are loaded first, you still see the stacked and loading views of the fragments before the final overlay view pops into the window.
My next thought was to mark the containing views IN each fragment's layout set to android:visibility="None". This didn't work either, as I had to set them Visible before using the FragmentManager.beginTransation() to enable/disable the fragments. Setting them all to 'visible' cause the loading animations to not appear, but all three fragments end up visible for a split second before the Transaction hid/showed the right fragments.
I looked at - am still looking at - that link with the code, but I think because one of my fragments HAS a fragment IN it (sub Fragment?) it will cause the same problems I ran into at the start of the project when I tried to create the fragments programatically.
I have one more little trick to try with the visibility of the views in the fragments, before I jump back to getting it all done up in code to avoid the ugliness.
Thanks guys -
Mike
Hi everyone! I'm new in this forum but I have to admit that I have read it a couple of times to see great stuff!
I read this thread because I had the same question. The answers here are the first thing in mind when I had the problem. As I searched the web, I found a library called Progress Fragment by Evgeny Shishkin.
https:/ /github.com/johnkil/Android-ProgressFragment (I'm new so I can't post links for now, so you can copy/paste it )
One of the main features is that is compatible with devices using Android 1.6 and up!
It's really easy to use!
I hope this helps someone.
Guys -
Thanks for your help.
After working around, here's what I ended up with -
I can't create and attach (.replace) the fragments programatically, since one of the fragments has a MapFragment inside of it. (NOT a MapSupportFragment). This causes the .replace to need some overriding to handle a 'sub-fragment'.
Seeing as I found a good way to handle it - I decided not to override the .replace or the fragment manager. Instead, my main activity (posted earlier in the thread), I made all three fragments visibility:gone. This allows the main activity to launch to a blank (or set background) screen briefly before loading up the first fragment and hiding the others.
When I call my fragmentmanager() to show/hide the fragments, I simply set the visibility to 'view' at the same time. Seems kinda clunky, but it works well.
Thanks!
-Mike.

Noob layout issue - probably VERY EASY!!

I'm essentially trying to create a MadLibs app for my kids. I'll type in the text of the books they already have and they can play with it in the car. But I'm a noob and I haven't done much else other than the first few simple apps in tutorials - my brain got tired trying to figure out sqlite stuff, so this all went on the backburner and now here I am again giving it another effort.
So I was thinking something ridiculously simple, like just having a textview string of the first part of a sentence, then an edittext with a hint set for the type of word to fill in, followed by the rest of the sentence in another textview string. Lather, rinse, repeat. Easy, right?
I can't seem to figure out how to get the objects to flow properly in the layout... First problem is that the edittext is gigantic compared to the textview. I could probably figure that one out easy enough, but my second problem prevents me from actually seeing the effects of my changes, and that problem is that the text doesn't flow onto the next line.
I've tried linearlayout and relativelayout, but I'm turning here for some guidance before I waste countless hours. Should I just build each paragraph (textview) as a single string comprised of other strings and edittext variables?
Any help would be great appreciated. And remember: go easy on me.
Here's my current activity_main.xml:
Code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:orientation="horizontal">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/textBody01"
android:weight="1" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/hint_adjective"
android:weight="1" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/textBody02"
android:weight="1"/>
</LinearLayout>
etnpnys said:
I'm essentially trying to create a MadLibs app for my kids. I'll type in the text of the books they already have and they can play with it in the car. But I'm a noob and I haven't done much else other than the first few simple apps in tutorials - my brain got tired trying to figure out sqlite stuff, so this all went on the backburner and now here I am again giving it another effort.
Click to expand...
Click to collapse
Could you post a quick picture (just a rough one in paint or something) showing the desired layout ?
Absolutely. I'll mock one up and get it on here shortly.
Sent from my SPH-L710 using Tapatalk
PicomatStudios said:
Could you post a quick picture (just a rough one in paint or something) showing the desired layout ?
Click to expand...
Click to collapse
Here's a little bit of how I'm thinking this should work out pretty easily. In the end, I would like to have the filled-in words in bold red text and the rest of the body paragraphs as regular black text, and I would like to make the background black to hide the body of text. I would then have a button that calls a function to change the background to white to make the body text visible "onclick" -- or maybe toggle between black/white/whatever.
The first hurdle is right here with the layout. I mean, this is REALLY simple, right?
View attachment 2380717
etnpnys said:
Here's a little bit of how I'm thinking this should work out pretty easily. In the end, I would like to have the filled-in words in bold red text and the rest of the body paragraphs as regular black text, and I would like to make the background black to hide the body of text. I would then have a button that calls a function to change the background to white to make the body text visible "onclick" -- or maybe toggle between black/white/whatever.
The first hurdle is right here with the layout. I mean, this is REALLY simple, right?
View attachment 2380717
Click to expand...
Click to collapse
Maybe not that simple
As I understand it you want the text to flow continuously left-to-right, top-to-bottom, a bit like floating CSS layouts ?
That is you might want it to do...
Mary had a [edit text] lamb. Its
fleece was white as snow.
Where that's 2 TextViews with an EditText between them ?
You will struggle to do that on Android, since there is not built in concept of 'flow' as you may be imagining.
The closest you will get is a RelativeLayout but you'll have to work hard to line the views up correctly.
You could try something like this, or maybe this. The second one links here where there is somebody's FlowLayout code towards the end of the page. I haven't tried it but it looks close to what you need at first glance. The concept appears to be a ViewGroup which calculates where its children should be and positions them accordingly.
You get my ideas exactly. I'll look into those! Much appreciated!
Sent from my SPH-L710 using Tapatalk
Just to button this up, I wanted to chime in to let everybody know which direction I went.
Basically, I have a vertical linear layout comprised of:
several editText fields for user input. @hint points to strings that indicate what kind of word (noun, adjective, etc) needs to be filled in.
a "Create" button
a "Clear" button
a textView
Behind the scenes, I set a series of "sentenceFragment" variables that contain the body text. Those all end with a "[" and start with a "]" so that the filled-in words can be easily seen once the story is built. Users fill in the editText fields and click the "Create" button. When clicked, I used getText on each of the editTexts to store each as a string, then a "paragraph" variable is built from concatenating all of the sentenceFragments + editTexts, then I used setText to the textView to display the entire story below.
The "Clear" button then uses setText on the textView and the editTexts to blank them out.
So, in the end, the user is presented with stuff like:
Sometimes you just want to get a [green] car. In your search, you find several [bugs] on the seat.
Thanx for you help, everybody! Now I'm looking into putting a spinner at the top to let the user select different stories... Anybody wanna point me in the right direction there?

Dynamic text wrap

Hi,
In my application i am dynamically creating a table layout. In each row of the table layout have 3 text views. but the auto wrap of the text is not working on these text views in multiple screen resolutions.
vrenjithkr said:
Hi,
In my application i am dynamically creating a table layout. In each row of the table layout have 3 text views. but the auto wrap of the text is not working on these text views in multiple screen resolutions.
Click to expand...
Click to collapse
did you set the height and width to "wrap_content"? if yes and still didnt work try this
Code:
android:layout_weight="1"
android:ellipsize="none"
android:maxLines="100"
android:scrollHorizontally="false"
android:layout_weight="1" android:ellipsize="none" android:maxLines="100" android:scr
Thank you for reply. I am dynamically crating the table layout. How can give these details in activity class..
vrenjithkr said:
Thank you for reply. I am dynamically crating the table layout. How can give these details in activity class..
Click to expand...
Click to collapse
You need to specify the layout parameters look at this sample program of adding a text view
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:stretchColumns="0,1" android:id="@+id/main_table" android:layout_weight="1" android:layout_height="wrap_content" android:layout_width="match_parent"> </TableLayout>
Once you ready with basic blank table layout open your respective activity page and define the table element
TableLayout t1; TableLayout tl = (TableLayout) findViewById(R.id.main_table);
Create table row header to hold the column headings
TableRow tr_head = new TableRow(this); tr_head.setId(10); tr_head.setBackgroundColor(Color.GRAY); tr_head.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
Add two data sections to the table row
TextView label_date = new TextView(this); label_date.setId(20); label_date.setText("DATE"); label_date.setTextColor(Color.WHITE); label_date.setPadding(5, 5, 5, 5); tr_head.addView(label_date);// add the column to the table row here TextView label_weight_kg = new TextView(this); label_weight_kg.setId(21);// define id that must be unique label_weight_kg.setText("Wt(Kg.)"); // set the text for the header label_weight_kg.setTextColor(Color.WHITE); // set the color label_weight_kg.setPadding(5, 5, 5, 5); // set the padding (if required) tr_head.addView(label_weight_kg); // add the column to the table row here
Regards
MasterAwesome

Categories

Resources