Search Results

Search found 1331 results on 54 pages for 'listview'.

Page 18/54 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Safe, standard way to load images in ListView on a different thread?

    - by Po
    Before making this question, I have searched and read these ones: http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview http://stackoverflow.com/questions/1409623/android-issue-with-lazy-loading-images-into-a-listview My problem is I have a ListView, where: Each row contains an ImageView, whose content is to be loaded from the internet Each row's view is recycled as in ApiDemo's List14 What I want ultimately: Load images lazily, only when the user scrolls to them Load images on different thread(s) to maintain responsiveness My current approach: In the adapter's getView() method, apart from setting up other child views, I launch a new thread that loads the Bitmap from the internet. When that loading thread finishes, it returns the Bitmap to be set on the ImageView (I do this using AsyncTask or Handler). Because I recycle ImageViews, it may be the case that I first want to set a view with Bitmap#1, then later want to set it to Bitmap#2 when the user scrolls down. Bitmap#1 may happen to take longer than Bitmap#2 to load, so it may end up overwriting Bitmap#2 on the view. I solve this by maintaining a WeakHashMap that remembers the last Bitmap I want to set for that view. Below is somewhat a pseudocode for my current approach. I've ommitted other details like caching, just to keep the thing clear. public class ImageLoader { // keeps track of the last Bitmap we want to set for this ImageView private static final WeakHashMap<ImageView, AsyncTask> assignments = new WeakHashMap<ImageView, AsyncTask>(); /** Asynchronously sets an ImageView to some Bitmap loaded from the internet */ public static void setImageAsync(final ImageView imageView, final String imageUrl) { // cancel whatever previous task AsyncTask oldTask = assignments.get(imageView); if (oldTask != null) { oldTask.cancel(true); } // prepare to launch a new task to load this new image AsyncTask<String, Integer, Bitmap> newTask = new AsyncTask<String, Integer, Bitmap>() { protected void onPreExecute() { // set ImageView to some "loading..." image } protected Bitmap doInBackground(String... urls) { return loadFromInternet(imageUrl); } protected void onPostExecute(Bitmap bitmap) { // set Bitmap if successfully loaded, or an "error" image if (bitmap != null) { imageView.setImageBitmap(bitmap); } else { imageView.setImageResource(R.drawable.error); } } }; newTask.execute(); // mark this as the latest Bitmap we want to set for this ImageView assignments.put(imageView, newTask); } /** returns (Bitmap on success | null on error) */ private Bitmap loadFromInternet(String imageUrl) {} } Problem I still have: what if the Activity gets destroyed while some images are still loading? Is there any risk when the loading thread calls back to the ImageView later, when the Activity is already destroyed? Moreover, AsyncTask has some global thread-pool underneath, so if lengthy tasks are not canceled when they're not needed anymore, I may end up wasting time loading things users don't see. My current design of keeping this thing globally is too ugly, and may eventually cause some leaks that are beyond my understanding. Instead of making ImageLoader a singleton like this, I'm thinking of actually creating separate ImageLoader objects for different Activities, then when an Activity gets destroyed, all its AsyncTask will be canceled. Is this too awkward? Anyway, I wonder if there is a safe and standard way of doing this in Android. In addition, I don't know iPhone but is there a similar problem there and do they have a standard way to do this kind of task? Many thanks.

    Read the article

  • How do I link one listview to another to create a football league table?

    - by Richard Nixon
    Hi I am creating a football system in windows forms c#. I have one listview where data is entered. I have 4 columns, 2 with team names linked to combo boxes and 2 with the scores linked to numericupdown controls. There are 3 buttons to add the results, Remove and clear. the code is below: private void addButton_Click(object sender, EventArgs e) { { ListViewItem item = new ListViewItem(comboBox1.SelectedItem.ToString()); item.SubItems.Add(numericUpDown1.Value.ToString()); item.SubItems.Add(numericUpDown2.Value.ToString()); item.SubItems.Add(comboBox2.SelectedItem.ToString()); listView1.Items.Add(item); } } private void clearButton_Click(object sender, EventArgs e) { listView1.Items.Clear(); } private void removeButton_Click(object sender, EventArgs e) { foreach (ListViewItem itemSelected in listView1.SelectedItems) { listView1.Items.Remove(itemSelected); } } I have another listview that i want to link the first one to. The second one is a usual english football league table and i want to use maths to add up the games played and the points etc. please help. cheers

    Read the article

  • How to set image Tag URLs programmatically in ASP.NET C# inside of a ListView Control?

    - by loyalpenguin
    Hi, I know how you can set an tag's url attribute programmatically in c#, but it seems when I try to access the image element inside of a tag I cannot access it. The is residing in the . NOTE: I am only having this issue inside the Now the ListView tag is also databound.(this is probably why I cannot access, because it isn't guaranteed that it will even exist perhaps). How can I get around this so that I can display my images programmatically or is there a better solution? Here's the source: <asp:ListView ID="ListView_Comments" runat="server" DataKeyNames="ReviewID,ProductID,Rating" DataSourceID="EDS_CommentsList"> <ItemTemplate> <tr style="background-color:#EDECB3;color: #000000;"> <td><%# Eval("CustomerName") %></td> <td> <img src='Styles/Images/ReviewRating_d<%# Eval("Rating") %>.gif' alt=""> <br /> </td> <td> <%# Eval("Comments") %> </td> </tr> </ItemTemplate> <AlternatingItemTemplate> <tr style="background-color:#F8F8F8;"> <td><%# Eval("CustomerName") %></td> <td> <img id="rateImage" src="" alt="" runat="server" /> ......

    Read the article

  • How to Identify a ListViewItem to Update a Single Row

    - by tunneling
    I have a ListView displays information about an object. When I click a ListView Item, I open an Activity that let's me manipulate parameters of the object held in the adapter. These parameters are updated and stored remotely. When I return to the ListView (via the back button), I want to update the ListView Item that I clicked originally by requesting the parameter values from the remote server. I am currently doing this up updating the entire ListView by clearing it and rebuilding it. How do I reference the ListView Item so that I can update the data for that item only? Thanks, Jason

    Read the article

  • What is the best way to do multiple listviews in android?

    - by Nicos
    Hi all, i am writing a software that i have to drill down on content a lot. For example when the program starts a listview is displayed. When user clicks on an item, then a second listview must be displayed. For example: Select Continent Select Country Select State Select City Select Address What is the best way to do this (less memory, faster, easier to code etc)? To create multiple listviews with multiple adapters? Or 1 listview with multiple Adapters? Lists are loaded from an external XML File. So far i am creating a new adapter and setting it to the listview. How do i create a second listview and after clicking on 1st listview displaying the second one, with animation. Any examples? Extend my class to ListActivity or Activity? Best regards and thanks for helping, Nicos

    Read the article

  • Adding a row to a ListView that displays "Loading" while information is downloaded. Like in the Market.

    - by user577139
    I've tried, but have had no luck trying to find this answer elsewhere. I want to add a row to the bottom of my listview that displays "Loading..." and maybe a spinning progress indicator. My program already loads additional information into the listview once the user scrolls to the bottom. But I want the user to be able to see that the program is indeed loading something. Example: If you go to the android marketplace and scroll to the bottom of one of the lists, the last row will say "Loading...". Then once the data is loaded, that bar is replaced with the first item of the new data. Sorry, it's a little hard to describe. I am NOT trying to add a footer to the bottom of the list view. I want it to be an actual item in the listview.

    Read the article

  • Is it possible to do custom grouping in the ASP.NET ListView control?

    - by michielvoo
    You can only define a GroupItemCount in the ListView, but what if you want to do grouping based on a property of the items in the data source? Sort of an ad-hoc group by. The data source is sorted on this property. I have seen some examples where some markup in the ItemTemplate was conditionally show, but I want to leverage the GroupTemplate if possible. Is this possible?

    Read the article

  • How to change the divider height of listview dynamically?

    - by sunil
    Hi, I have a listview in which there should be different divider height between different rows. So, how can we set the divider height dynamically? Suppose, I have 10 rows and there should be a divider height of 5 between first 2 rows and then there should be a divider height of 1 between next 5 rows and so on. Can someone let me know the way of doing this? Regards Sunil

    Read the article

  • How to make a row of ListView like this?

    - by Jack101
    Hello, Sorry, this's my first time to ask a question here. So, I don't have the permission to upload the image to describe. Never Mind. What I would like to make is a row of ListView like this. The block on the left is an icon. Much appreciated if you could feedback the correct XML tags. Thanks. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ------- | | some text some text | | some text some text ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Read the article

  • Is there any way to sync the scrollbars in a JavaFX 1.2 ListView?

    - by Xystus7777
    I have multiple listviews sidebyside. I have a way to make sure the "selectedIndex" is the same on all of them, but is there a way to make it so the scrollbar's are ALWAYS synchronized? It seems that the scrollbars WILL be synced as long as the user uses the ARROW KEYS when navigating down the listview, however, if the user HOLDS DOWN the key, OR USES THE MOUSE WHEEL, they will not be synchronized at all. Thanks in advance! Andrew Davis NASA - Kennedy Space Center

    Read the article

  • How can I make sure a ListView item always resizes to show all rows?

    - by Jon Cage
    I have a panel which contains a TableLayoutPanel which itself contains a number of ListViews and Labels. What I'd like is for each list view to resize to fit all of it's contents in vertically (i.e. so that every row is visible). The TableLayoutPanel should handle any vertical scrolling but I can't work out how to get the ListView to resize itself depending on the number of rows. Do I need to handle OnResize and manually resize or is there already something to handle this?

    Read the article

  • Is it possible to make ListView display a text obtained through its ListViewItem.Tag?

    - by Dimitri C.
    I'd like to fill System.Windows.Forms.ListView with the items I've stored in a separate System.Collections.Generics.List<. I would like to avoid to store the data twice, once in the List< and once as a string in ListViewItem. Is there a way to make ListViewItem use some callback function to obtain the text to put in its columns from the Tag property, instead of using its Text property?

    Read the article

  • Send a double click to a listview (c++, not .net!)

    - by Jorge Branco
    Hello. I want to send a double click to a listview. From what I've read on msdn it seems I gotta send a WM_NOTIFY message and something with NM_DBLCLK. But I do not understand really well hwo to implement it. I've worked with SendMessage before but MSDN is not that clear on how to fill the structs and so: WM_NOTIFY http://msdn.microsoft.com/en-us/library/bb775583(VS.85).aspx NM_DBLCLK http://msdn.microsoft.com/en-us/library/bb774867(VS.85).aspx

    Read the article

  • Another ArrayIndexOutOfBoundsException in ListView

    - by synic
    This one is different than the other one I posted. Any ideas? java.lang.IndexOutOfBoundsException: Invalid location 14, size is 1 at java.util.ArrayList.get(ArrayList.java:341) at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:188) at android.widget.AbsListView.obtainView(AbsListView.java:1256) at android.widget.ListView.makeAndAddView(ListView.java:1668) at android.widget.ListView.fillUp(ListView.java:667) at android.widget.ListView.fillGap(ListView.java:613) at android.widget.AbsListView.trackMotionScroll(AbsListView.java:2531) at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:2353) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:4595) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) at dalvik.system.NativeStart.main(Native Method)

    Read the article

  • Problem in Setting image in imageview inside ListView in Android?

    - by sunil
    Hi, I have a listview which includes 2 textviews and 1 imageview. Now, the image in imageview will be set on certain conditions otherwise it should be left blank with no image. The problem is the images are not coming in proper rows. Say, for eg the image should be displayed at row 3 but its displayed at row 4. And, in some cases each row will have the same image. Has someone faced this kind of an issue? I am really clueless about the reason behind this. Can anyone point out the problem? Regards Sunil

    Read the article

  • Android: Context menu doesn't show up for ListView with members defined by LinearLayout?

    - by RandomEngy
    I've got a ListActivity and ListView and I've bound some data to it. The data shows up fine, and I've also registered a context menu for the view. When I display the list items as just a simple TextView, it works fine: <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/nametext" android:layout_width="wrap_content" android:layout_height="wrap_content"/> However when I try something a bit more complex, like show the name and a CheckBox, the menu never shows up: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:id="@+id/nametext" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <CheckBox android:id="@+id/namecheckbox" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> Can long-presses work on more complex elements? I'm building on 2.1.

    Read the article

  • Can checkboxes be removed from a .NET WinForms ListView at runtime?

    - by James
    Is it possible to remove the checkboxes from a .NET WinForms ListView control at runtime? The following code appears to have no effect when '.Checkboxes' has initially been set to 'true' and the control has rendered onto a form with checkboxes available for each list view item: // C#: testListView.BeginUpdate(); testListView.Checkboxes = false; testListView.EndUpdate(); Is there a method that must be called to enact this change? What is the use of providing the .Checkboxes property when it defaults to 'false' and only has an effect if set to 'true'?

    Read the article

  • How can I get unfiltered position in filtered ListView?

    - by Julius
    I am using ListView with ArrayAdapter to filter items in list. I have implemented onListItemClick() method to get clicked item position and call second activity using that value. For example I have countries in my list: Australia Belgium Botswana Belize ... Belgium has position 1 here. However, if i type "Be" to filter items, I get one item as a result: Belgium Now if I click on this item, I get position 0 in onListItemClick(). But this behavior does not fit my needs. How can I get this item's unfiltered position (eg. 1 instead of 0)?

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >