Tuesday, November 16, 2010

[android-developers] Re: Problem with UI Thread which hangs up

Thanks Kostya

Problem is not with sorting. Problem is as follows:

I have three view to be shown. First white article, Second grey
article and third is the belt which shows date.
I wanted to know how to handle such things in getView.


On Nov 16, 10:48 pm, Kostya Vasilyev <kmans...@gmail.com> wrote:
> If you need your data to be ordered - sort it.
>
> For in-memory sort, before adding data to ListView, take a look at
> Collections.sort (it's part of Java).
>
> http://download.oracle.com/javase/tutorial/collections/interfaces/ord...
>
> If get data for your ListView from a database, use a SELECT with ORDER
> BY clause.
>
> http://www.sql-tutorial.net/SQL-ORDER-BY.asp
>
> -- Kostya
>
> 16.11.2010 20:32, umakantpatil пишет:
>
>
>
>
>
>
>
>
>
> > Thanks Kostya..
> > Point one I can do.
> > But if you see my image i.e. feeds are sort based on dates under the
> > date row.
> > thats what I find difficult. Can you give me a short code sample for a
> > getview  method which solves my problem?
>
> > On Nov 16, 10:07 pm, Kostya Vasilyev<kmans...@gmail.com>  wrote:
> >> Umakant,
>
> >> I suggest you take another go at making ListView work. It's just better
> >> for memory usage and the initial time to bring up the UI.
>
> >> You have two options:
>
> >> - In the getView method of the adapter, set the background color from
> >> code, based on the index of the list item (odd ->  white, even ->  light
> >> gray).
>
> >> - Implement odd / even item views as two distinct layouts. For this,
> >> override getViewTypeCount and getItemViewType in the adapter, and
> >> inflate one of two layouts in getView.
>
> >> With the second way, you'd have more flexibility for making odd / even
> >> list items different, such as playing with indentation or alignment.
>
> >> -- Kostya
>
> >> 16.11.2010 19:38, Streets Of Boston пишет:
>
> >>> This is not about the hanging/freezing of your UI, but not using a
> >>> listview for your articles may pose another problem. If you have a lot
> >>> of articles to show, the number of children (i.e. TableRows) may
> >>> become too large and you'll get UI problems (UI too 'wide').
> >>> ListView get around this problem because they re-use the list-item
> >>> views (by calling the list-adapter's getView(...) method and allowing
> >>> to re-use a contentVie (list-item view)).
> >>> On Nov 16, 8:41 am, umakantpatil<umakantpat...@gmail.com>    wrote:
> >>>> Hi all,
> >>>> I have to draw list of 30 articles. I tired using list view but there
> >>>> was some problem as I wanted to user alternate colors like first is
> >>>> white and 2nd is blue where as again 3rd is white and 4th is blue and
> >>>> it goes on..
> >>>> So I decided to have scrollview and table into it.
> >>>> I set the view using setcontentview which shows loading dialog.
> >>>> then in aysnc task's "doInBackground" method i fetch all articles into
> >>>> the object and then in "onPostExecute"
> >>>> I run a for loop on the object and in each loop i make table row
> >>>> insert article and then insert row into table.
> >>>> and then dismiss loading dialog box.
> >>>> As i have tabular view in my app and If i remove loading dialog box.
> >>>> While the UI is rendered if someone clicks on other tab. UI is hanged
> >>>> up,
> >>>> After loading all table rows It goes to other tab.
> >>>> Can some one help me with this ? Even after using asynctask why this
> >>>> happens ?
> >> --
> >> Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com
>
> --
> Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate