Re: [android-developers] Re: Using an image in a listview
Hi, i've tried the list13 implementation, but although scrolling seems smoother then it ever was, i'm kinda displeased with the time it takes to fill the rows with content. I think my main concern is related to the reuse of the rows, rather then how to fill them. I am wondering if there isn't a way to prefill the listview and don;t reuse anything? Regards, Patrick 2010/1/6 Patrick Plaatje pplaa...@gmail.com: Hi Brion, if this arraylist would be a rather big list, it would be costly indeed, and it is a good suggestion. This list consists of just 10 items (feedmessage objects) though. These feedmessages are just a set of getters and setters (of just small String objects) and are not doin any costly operations internally. I will try your suggestion though to see if this will help. I'm kinda clueless on what is so costly Thanx for the suggestions, and will let you know tomorrow! Best, Patrick 2010/1/6 Brion Emde brione2...@gmail.com: I see some problems here: // Bind the data efficiently with the holder. holder.titleText.setText(Html.fromHtml(((FeedMessage)Items.get (position)).g etTitle())); holder.descriptionText.setText(Html.fromHtml(((FeedMessage)Items.get (positi on)).getDescription())); Drawable d = null; FeedMessage fm = (FeedMessage) Items.get(position); if that Items.get(position) is costly, you're wasting it, above. How about: // Bind the data efficiently with the holder. Drawable d = null; FeedMessage fm = (FeedMessage) Items.get(position); holder.titleText.setText(Html.fromHtml(fm.getTitle ())); holder.descriptionText.setText(Html.fromHtml (fm.getDescription())); On Jan 6, 12:57 pm, Patrick Plaatje pplaa...@gmail.com wrote: Hi, i've used the holder method, but adding or omitting this didn;t give me an increase or decrease in performance, my getView method is below: @Override public View getView(int position, View convertView, ViewGroup parent) { // A ViewHolder keeps references to children views to avoid unneccessary calls // to findViewById() on each row. ViewHolder holder; holder = new ViewHolder(); // When convertView is not null, we can reuse it directly, there is no need // to reinflate it. We only inflate a new View when the convertView supplied // by ListView is null. if (convertView == null){ convertView = mInflater.inflate(R.layout.article_row, null); // Creates a ViewHolder and store references to the two children views // we want to bind data to. holder.titleText = (TextView) convertView.findViewById(R.id.article_title); holder.descriptionText = (TextView) convertView.findViewById(R.id.article_description); holder.icon = (ImageView) convertView.findViewById(R.id.article_thumb); convertView.setTag(holder); } else { // get holder back...much faster than inflate holder = (ViewHolder) convertView.getTag(); } // Bind the data efficiently with the holder. holder.titleText.setText(Html.fromHtml(((FeedMessage)Items.get(position)).g etTitle())); holder.descriptionText.setText(Html.fromHtml(((FeedMessage)Items.get(positi on)).getDescription())); Drawable d = null; FeedMessage fm = (FeedMessage) Items.get(position); if(fm.getEnclosures().size() 0){ String urlString = fm.getEnclosures().get(0); dm.fetchDrawableOnThread(urlString, holder.icon); } else { d = _context.getResources().getDrawable(R.drawable.thumb_holder); holder.icon.setImageDrawable(d); } if(fm.getGuid() != null){ convertView.setId(position); } return convertView; } static class ViewHolder { TextView descriptionText; TextView titleText; ImageView icon; } regards, Patrick 2010/1/6 Vince specialized...@gmail.com: What does your getView code look like. Are re-inflating your row view every time it's called, are there multiple views for the rows etc? Vince On Jan 6, 10:18 am, Patrick Plaatje patrick.plaa...@ndcvbk.nl wrote: Hi all, for my app i'm using a listview to display rss news articles. All goes well, and the implementation is almost done. But when using my app, i'm not really satisfied with the smoothness and user experience of it. The main problem is that when i scroll through the listview, which contains an image for each row
[android-developers] Using an image in a listview
Hi all, for my app i'm using a listview to display rss news articles. All goes well, and the implementation is almost done. But when using my app, i'm not really satisfied with the smoothness and user experience of it. The main problem is that when i scroll through the listview, which contains an image for each row in the listview, the scrolling isn;t smooth, it executes the getview override every time. I already threw out the holder startegy, as it slowed the scrolling... any thoughts? Thanx, Patrick -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Using an image in a listview
Hi Brion, thanks, i will certainly give that a try. But the funy thing is that i'm actually not attaching that much data to my listview rows. I even stripped the images from it and i still have some hickups when scrolling. And it's indeed probably the getview method which tries to attach the data to the view. But as said i'll give the example a go and see if that helps. Many thanx in advance. Patrick 2010/1/6 Brion Emde brione2...@gmail.com: Are you using any of the techniques shown in the List13.java example in the APIDemos? I have a video example of what can be achieved with such techniques, here: http://www.youtube.com/watch?v=QZ8PoS6ai6U On Jan 6, 8:18 am, Patrick Plaatje patrick.plaa...@ndcvbk.nl wrote: Hi all, for my app i'm using a listview to display rss news articles. All goes well, and the implementation is almost done. But when using my app, i'm not really satisfied with the smoothness and user experience of it. The main problem is that when i scroll through the listview, which contains an image for each row in the listview, the scrolling isn;t smooth, it executes the getview override every time. I already threw out the holder startegy, as it slowed the scrolling... any thoughts? Thanx, Patrick -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Met vriendelijke groet, Patrick Plaatje NDC|VBK de uitgevers Sixmastraat 32, 8915 PA Leeuwarden Postbus 394, 8901 BD Leeuwarden T (058) - 284 5044 M (06) - 158 966 34 -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Using an image in a listview
Hi, i've used the holder method, but adding or omitting this didn;t give me an increase or decrease in performance, my getView method is below: @Override public View getView(int position, View convertView, ViewGroup parent) { // A ViewHolder keeps references to children views to avoid unneccessary calls // to findViewById() on each row. ViewHolder holder; holder = new ViewHolder(); // When convertView is not null, we can reuse it directly, there is no need // to reinflate it. We only inflate a new View when the convertView supplied // by ListView is null. if (convertView == null){ convertView = mInflater.inflate(R.layout.article_row, null); // Creates a ViewHolder and store references to the two children views // we want to bind data to. holder.titleText = (TextView) convertView.findViewById(R.id.article_title); holder.descriptionText = (TextView) convertView.findViewById(R.id.article_description); holder.icon = (ImageView) convertView.findViewById(R.id.article_thumb); convertView.setTag(holder); } else { // get holder back...much faster than inflate holder = (ViewHolder) convertView.getTag(); } // Bind the data efficiently with the holder. holder.titleText.setText(Html.fromHtml(((FeedMessage)Items.get(position)).getTitle())); holder.descriptionText.setText(Html.fromHtml(((FeedMessage)Items.get(position)).getDescription())); Drawable d = null; FeedMessage fm = (FeedMessage) Items.get(position); if(fm.getEnclosures().size() 0){ String urlString = fm.getEnclosures().get(0); dm.fetchDrawableOnThread(urlString, holder.icon); } else { d = _context.getResources().getDrawable(R.drawable.thumb_holder); holder.icon.setImageDrawable(d); } if(fm.getGuid() != null){ convertView.setId(position); } return convertView; } static class ViewHolder { TextView descriptionText; TextView titleText; ImageView icon; } regards, Patrick 2010/1/6 Vince specialized...@gmail.com: What does your getView code look like. Are re-inflating your row view every time it's called, are there multiple views for the rows etc? Vince On Jan 6, 10:18 am, Patrick Plaatje patrick.plaa...@ndcvbk.nl wrote: Hi all, for my app i'm using a listview to display rss news articles. All goes well, and the implementation is almost done. But when using my app, i'm not really satisfied with the smoothness and user experience of it. The main problem is that when i scroll through the listview, which contains an image for each row in the listview, the scrolling isn;t smooth, it executes the getview override every time. I already threw out the holder startegy, as it slowed the scrolling... any thoughts? Thanx, Patrick -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Met vriendelijke groet, Patrick Plaatje NDC|VBK de uitgevers Sixmastraat 32, 8915 PA Leeuwarden Postbus 394, 8901 BD Leeuwarden T (058) - 284 5044 M (06) - 158 966 34 -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Using an image in a listview
Hi Brion, if this arraylist would be a rather big list, it would be costly indeed, and it is a good suggestion. This list consists of just 10 items (feedmessage objects) though. These feedmessages are just a set of getters and setters (of just small String objects) and are not doin any costly operations internally. I will try your suggestion though to see if this will help. I'm kinda clueless on what is so costly Thanx for the suggestions, and will let you know tomorrow! Best, Patrick 2010/1/6 Brion Emde brione2...@gmail.com: I see some problems here: // Bind the data efficiently with the holder. holder.titleText.setText(Html.fromHtml(((FeedMessage)Items.get (position)).g etTitle())); holder.descriptionText.setText(Html.fromHtml(((FeedMessage)Items.get (positi on)).getDescription())); Drawable d = null; FeedMessage fm = (FeedMessage) Items.get(position); if that Items.get(position) is costly, you're wasting it, above. How about: // Bind the data efficiently with the holder. Drawable d = null; FeedMessage fm = (FeedMessage) Items.get(position); holder.titleText.setText(Html.fromHtml(fm.getTitle ())); holder.descriptionText.setText(Html.fromHtml (fm.getDescription())); On Jan 6, 12:57 pm, Patrick Plaatje pplaa...@gmail.com wrote: Hi, i've used the holder method, but adding or omitting this didn;t give me an increase or decrease in performance, my getView method is below: @Override public View getView(int position, View convertView, ViewGroup parent) { // A ViewHolder keeps references to children views to avoid unneccessary calls // to findViewById() on each row. ViewHolder holder; holder = new ViewHolder(); // When convertView is not null, we can reuse it directly, there is no need // to reinflate it. We only inflate a new View when the convertView supplied // by ListView is null. if (convertView == null){ convertView = mInflater.inflate(R.layout.article_row, null); // Creates a ViewHolder and store references to the two children views // we want to bind data to. holder.titleText = (TextView) convertView.findViewById(R.id.article_title); holder.descriptionText = (TextView) convertView.findViewById(R.id.article_description); holder.icon = (ImageView) convertView.findViewById(R.id.article_thumb); convertView.setTag(holder); } else { // get holder back...much faster than inflate holder = (ViewHolder) convertView.getTag(); } // Bind the data efficiently with the holder. holder.titleText.setText(Html.fromHtml(((FeedMessage)Items.get(position)).g etTitle())); holder.descriptionText.setText(Html.fromHtml(((FeedMessage)Items.get(positi on)).getDescription())); Drawable d = null; FeedMessage fm = (FeedMessage) Items.get(position); if(fm.getEnclosures().size() 0){ String urlString = fm.getEnclosures().get(0); dm.fetchDrawableOnThread(urlString, holder.icon); } else { d = _context.getResources().getDrawable(R.drawable.thumb_holder); holder.icon.setImageDrawable(d); } if(fm.getGuid() != null){ convertView.setId(position); } return convertView; } static class ViewHolder { TextView descriptionText; TextView titleText; ImageView icon; } regards, Patrick 2010/1/6 Vince specialized...@gmail.com: What does your getView code look like. Are re-inflating your row view every time it's called, are there multiple views for the rows etc? Vince On Jan 6, 10:18 am, Patrick Plaatje patrick.plaa...@ndcvbk.nl wrote: Hi all, for my app i'm using a listview to display rss news articles. All goes well, and the implementation is almost done. But when using my app, i'm not really satisfied with the smoothness and user experience of it. The main problem is that when i scroll through the listview, which contains an image for each row in the listview, the scrolling isn;t smooth, it executes the getview override every time. I already threw out the holder startegy, as it slowed the scrolling... any thoughts? Thanx, Patrick -- 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
[android-developers] strings.xml resource
Hi All, i was wondering if i could put extra attributes in a strings.xml resource. I need more metadata for the value in this resource and it seems to me that if i could read those extra attributes from the static R reference, it saves me resources over implementing an xml reader. So what i actually try to do is access the following xml: ?xml version=1.0 encoding=utf-8? resources string name=index url=http://www.this.com/;Frontpage/string string name=sport url=http://www.this2.com/;Sport/string /resources Any suggestions? Regards, Patrick -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Display numeric entities (eg. #35;) in TextView or WebView
Hi All, i'm trying to process text which i'm receiving from a RSS feed. In this feed all special characters are defined as numeric entities. When i try to display these texts in a Text- or WebView, it stops displaying anything after encountering the numeric entity. Any thoughts? Regards, Patrick -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: button Click event inside custom listview.... Help!
Abhishek, it's kinda hard to resolve this without any code, but here's how i solved it: in the main activity, i defined the following: setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView? arg0, View arg1, int arg2, long arg3) { Log.d(this.getClass().getSimpleName, arrayList.get((int) arg3).toString); }}); so within the onItemClickListener, i make a reference to my ArrayList and show them in the log. Hopes it helps, Regards, Patrick 2009/12/21 Abhi abhishek.r.sha...@gmail.com That didn't help. :( Can someone guide me to the right tutorial/sample code? Thanks, Abhishek On Dec 18, 11:03 pm, android09 pranav.jaja...@gmail.com wrote: Hi Abhishek, You can to through the below example for creatingcustomview. Follow the below link. http://www.anddev.org/basic_drag_and_drop-t3095.html I hope you will get the something from the above example. Best Luck. Thanks. On Dec 18, 7:47 am, Abhi abhishek.r.sha...@gmail.com wrote: Hi guys, I have my owncustomadapter to create acustomlistviewwith checkbox, textview and button in each row. I want to implement onClick on Button and take different action based on which row button is pressed. How can I use onClickListener in this case? Define it inside getView? If so how? Thanks Abhishek- Hide quoted text - - Show quoted text - -- 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+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Met vriendelijke groet, Patrick Plaatje NDC|VBK de uitgevers Sixmastraat 32, 8915 PA Leeuwarden Postbus 394, 8901 BD Leeuwarden T (058) - 284 5044 M (06) - 158 966 34 -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: button Click event inside custom listview.... Help!
My Apologies, i didn;t see the complete message thread earlier (thanx Gmail!). I hope my post did help you though. If not, reply again and i'll see if i can help. Regards, Patrick -- Forwarded message -- From: Patrick Plaatje pplaa...@gmail.com Date: 2009/12/21 Subject: Re: [android-developers] Re: button Click event inside custom listview Help! To: android-developers@googlegroups.com Abhishek, it's kinda hard to resolve this without any code, but here's how i solved it: in the main activity, i defined the following: setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView? arg0, View arg1, int arg2, long arg3) { Log.d(this.getClass().getSimpleName, arrayList.get((int) arg3).toString); }}); so within the onItemClickListener, i make a reference to my ArrayList and show them in the log. Hopes it helps, Regards, Patrick 2009/12/21 Abhi abhishek.r.sha...@gmail.com That didn't help. :( Can someone guide me to the right tutorial/sample code? Thanks, Abhishek On Dec 18, 11:03 pm, android09 pranav.jaja...@gmail.com wrote: Hi Abhishek, You can to through the below example for creatingcustomview. Follow the below link. http://www.anddev.org/basic_drag_and_drop-t3095.html I hope you will get the something from the above example. Best Luck. Thanks. On Dec 18, 7:47 am, Abhi abhishek.r.sha...@gmail.com wrote: Hi guys, I have my owncustomadapter to create acustomlistviewwith checkbox, textview and button in each row. I want to implement onClick on Button and take different action based on which row button is pressed. How can I use onClickListener in this case? Define it inside getView? If so how? Thanks Abhishek- Hide quoted text - - Show quoted text - -- 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+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Met vriendelijke groet, Patrick Plaatje NDC|VBK de uitgevers Sixmastraat 32, 8915 PA Leeuwarden Postbus 394, 8901 BD Leeuwarden T (058) - 284 5044 M (06) - 158 966 34 -- Met vriendelijke groet, Patrick Plaatje NDC|VBK de uitgevers Sixmastraat 32, 8915 PA Leeuwarden Postbus 394, 8901 BD Leeuwarden T (058) - 284 5044 M (06) - 158 966 34 -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: button Click event inside custom listview.... Help!
Hi Abhishek, what i did in my solution was not setting the onClick listener in the getView method, but rather attach an onItemClickListener to the listview: lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView? arg0, View arg1, int arg2, long arg3) { Intent i = new Intent(act, ArticleDetail.class); Log.d(Clicked, args= + arg0 + , + arg1 + , + arg2 + , +arg3); i.putExtra(articleId, messages.get((int) arg3).getGuid()); act.startActivity(i); } }); where lv is a ListView object. The arg3 long is getting the position of the view, which in my case corresponds to the position in my arraylist. So a click on my row starts creates a new Intent and starts the activity. This solution however is just for a ListView object as you attach an onclick listener to the complete item of the listview. Is your objective similar of do you need the actual buttonclick? Regards, Patrick 2009/12/21 Abhi abhishek.r.sha...@gmail.com Hi Patrick, Thanks for getting back. I don't think I understand your solution completely. Maybe I am too exhausted to think straight. Here is what I am trying to do, I have a custom listview with an icon, textview and button on each row. There are 6 items in the listview and each row button would bring up a different activity. I want to define button onClick event inside my getView method to listen to the button clicks on each row and take necessary action. As you can see, I am setting the row icons under getView based on position. I want to use the position information to now listen to respective button clicks. Clueless! Would you be able to help? class CustomAdapter extends ArrayAdapter { CustomAdapter() { super(kis.this, R.layout.row_kis, items); } public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater=getLayoutInflater(); View row=inflater.inflate(R.layout.row_kis, parent, false); TextView label=(TextView)row.findViewById (R.id.label); label.setText(items[position]); ImageView icon=(ImageView)row.findViewById (R.id.icon); Button row_button = (Button) findViewById (R.id.btlst1); if (items[position].compareTo(Abhi) == 0) { icon.setImageResource (R.drawable.alan); //set icon for row with name Abhi } .. and so on for other rows } } Thanks, Abhishek On Dec 21, 4:31 pm, Patrick Plaatje pplaa...@gmail.com wrote: My Apologies, i didn;t see the complete message thread earlier (thanx Gmail!). I hope my post did help you though. If not, reply again and i'll see if i can help. Regards, Patrick -- Forwarded message -- From: Patrick Plaatje pplaa...@gmail.com Date: 2009/12/21 Subject: Re: [android-developers] Re: button Click event inside custom listview Help! To: android-developers@googlegroups.com Abhishek, it's kinda hard to resolve this without any code, but here's how i solved it: in the main activity, i defined the following: setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView? arg0, View arg1, int arg2, long arg3) { Log.d(this.getClass().getSimpleName, arrayList.get((int) arg3).toString); }}); so within the onItemClickListener, i make a reference to my ArrayList and show them in the log. Hopes it helps, Regards, Patrick 2009/12/21 Abhi abhishek.r.sha...@gmail.com That didn't help. :( Can someone guide me to the right tutorial/sample code? Thanks, Abhishek On Dec 18, 11:03 pm, android09 pranav.jaja...@gmail.com wrote: Hi Abhishek, You can to through the below example for creatingcustomview. Follow the below link. http://www.anddev.org/basic_drag_and_drop-t3095.html I hope you will get the something from the above example. Best Luck. Thanks. On Dec 18, 7:47 am, Abhi abhishek.r.sha...@gmail.com wrote: Hi guys, I have my owncustomadapter to create acustomlistviewwith checkbox, textview and button in each row. I want to implement onClick on Button and take different action based on which row button is pressed. How can I use onClickListener in this case? Define it inside getView? If so how? Thanks Abhishek- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups
Re: [android-developers] ViewFlipper.showNext() not working in timer
Hi, Be aware that the timer uses a new thread, so you need a handle to communicate with the UI thread. Regards, Patrick -- verzonden vanaf mijn Android. Op 19 dec 2009 10:52 PM schreef Andy Triboletti andy.tribole...@gmail.com : I have some webimageviews inside a viewflipper, and I am setting a timer so that I can play a slideshow of the images. The problem is the timer function is getting called but the view is not actually advancing. If I call the viewFlipper.showNext outside of the timer, the image advances, but not inside the timer. I can't use viewFlipper.startFlipping because each time it flips I want to download a new image in the background. Here's my some of the code: public void playSlideshow() { Timer updateProgressTimer = null; updateProgressTimer = new Timer(); int delay = 5000; // delay for 5 sec. int period = 5000; // repeat every sec. updateProgressTimer.scheduleAtFixedRate(new TimerTask() { public void run() { System.out.println(done); moveRight(viewFlipper); } }, delay, period); } } public void moveRight(ViewFlipper vf) { Log.v(moving right, Integer.toString(imageCounter)); Log.v(moving right child, Integer.toString(vf.getDisplayedChild ())); vf.setInAnimation(slideLeftIn); vf.setOutAnimation(slideLeftOut); vf.showNext(); } -- 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+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Listview problems
Hi All, Struggling and struggling, but can't find the thing i'm doin wrong in my listview implementation. No exceptions, just no listview. I have a customized adapter with an overridden getView method, but the Log.d won't show, so i guess my adapter is just wrong? Could somebody have a look at the code below? Thanks in advance! Patrick public class ArticleList extends ListActivity { /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { // call super constructor super.onCreate(savedInstanceState); // set the layout used for this activity setContentView(R.layout.article_list); // create a new splashscreen and show it: SplashScreen ss = new SplashScreen(this); ss.show(); // now that we have the splash screen displayed fire up the // method that's going to fetch our content ArticleListView alv = new ArticleListView(this); alv.setSource(rss); alv.show(); ss.hide(); } public class ArticleListView { private String source=null; private ListView lv; public ArticleListView(ListActivity act) { // find the list view lv = (ListView) act.findViewById(android.R.id.list); // get the messages FeedManager fm = new FeedManager(); Feed f = fm.getFeed(Some valid feed url); ListFeedMessage messages = f.getMessages(); // get the adapter for the list ArticleDetailAdapter adp = new ArticleDetailAdapter(act, android.R.layout.simple_list_item_2, messages); lv.setAdapter(adp); } public void show(){ lv.setVisibility(View.VISIBLE); } public void hide(){ lv.setVisibility(View.GONE); } public void setSource(String source){ this.source = source; } public String getSource(){ return source; } } package nl.ipros.android.newsreader.util; import java.util.List; import nl.ipros.android.newsreader.R; import android.content.Context; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; public class ArticleDetailAdapter extends ArrayAdapter { private LayoutInflater mInflater; private List Items; @SuppressWarnings(unchecked) public ArticleDetailAdapter(Context context, int textViewResourceId, List Items) { super(context,android.R.id.list,Items); this.Items = Items; Log.d(here, ArticleDetailAdapter); mInflater = LayoutInflater.from(context); } @Override public View getView(int position, View convertView, ViewGroup parent) { Log.d(here, Getview method loading); // A ViewHolder keeps references to children views to avoid unneccessary calls // to findViewById() on each row. ViewHolder holder; // When convertView is not null, we can reuse it directly, there is no need // to reinflate it. We only inflate a new View when the convertView supplied // by ListView is null. if (convertView == null){ convertView = mInflater.inflate(R.layout.article_row, null); // Creates a ViewHolder and store references to the two children views // we want to bind data to. holder = new ViewHolder(); holder.titleText = (TextView) convertView.findViewById(R.id.article_title); holder.descriptionText = (TextView) convertView.findViewById(R.id.article_description); //holder.icon = (ImageView) convertView.findViewById(R.id.icon); } else { // Get the ViewHolder back to get fast access to the TextView // and the ImageView. holder = (ViewHolder) convertView.getTag(); } // Bind the data efficiently with the holder. holder.titleText.setText((CharSequence) Items.get(position)); holder.descriptionText.setText(description); //holder.icon.setImageBitmap((position 1) == 1 ? mIcon1 : mIcon2); return convertView; } static class ViewHolder { TextView descriptionText; TextView titleText; ImageView icon; } } -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Listview problems
Hi Mark, thanx for your amazing fast reply. All your remarks are very valid, but i might have oversimplified my code: - SplashScreen remark: i'm actually doin this with a timertask and a handler, is tested and working; - Feed is indeed retrieved in a seperate thread (as are the images for each message); - Valid feed messages are returned (adding these to a tableview for example is working); - i checked my List object though and messages.size() gives me 10. Your last remark is interesting though, how can i use the hierarchy viewer? Because when i use lv.getVisibility() it gives me 0 (what as far as i know means it's visible) Any more thoughts? Patrick 2009/12/14 Mark Murphy mmur...@commonsware.com Patrick Plaatje wrote: Hi All, Struggling and struggling, but can't find the thing i'm doin wrong in my listview implementation. No exceptions, just no listview. I have a customized adapter with an overridden getView method, but the Log.d won't show, so i guess my adapter is just wrong? Could somebody have a look at the code below? Thanks in advance! snip public class ArticleList extends ListActivity { /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { // call super constructor super.onCreate(savedInstanceState); // set the layout used for this activity setContentView(R.layout.article_list); // create a new splashscreen and show it: SplashScreen ss = new SplashScreen(this); ss.show(); // now that we have the splash screen displayed fire up the // method that's going to fetch our content ArticleListView alv = new ArticleListView(this); alv.setSource(rss); alv.show(); ss.hide(); } Your splash screen will never be shown, since you hide it before it is displayed. Remember that nothing you do in onCreate(), or any callback, will affect the screen until *after* the callback returns. If you are eventually going to do a real implementation of this, with HTTP retrieval of a feed, you are going to need to rework this code to take threading into account. You will not be successful retrieving a feed on the main application thread, as you will take too long and get the fabled application not responding (ANR) force-close dialog. You will need to do the retrieval in a background operation, perhaps using an AsyncTask. public class ArticleListView { private String source=null; private ListView lv; public ArticleListView(ListActivity act) { // find the list view lv = (ListView) act.findViewById(android.R.id.list); // get the messages FeedManager fm = new FeedManager(); Feed f = fm.getFeed(Some valid feed url); ListFeedMessage messages = f.getMessages(); // get the adapter for the list ArticleDetailAdapter adp = new ArticleDetailAdapter(act, android.R.layout.simple_list_item_2, messages); lv.setAdapter(adp); } public void show(){ lv.setVisibility(View.VISIBLE); } public void hide(){ lv.setVisibility(View.GONE); } public void setSource(String source){ this.source = source; } public String getSource(){ return source; } } You could use hierarchyviewer to see if your ListView is actually becoming visible. You could also check to see that f.getMessages() will return a non-empty list -- if the list is empty, getView() will not be called for any rows. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Training in Germany, 18-22 January 2010: http://bignerdranch.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+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Met vriendelijke groet, Patrick Plaatje NDC|VBK de uitgevers Sixmastraat 32, 8915 PA Leeuwarden Postbus 394, 8901 BD Leeuwarden T (058) - 284 5044 M (06) - 158 966 34 -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Listview problems
Hi Mark, the hierarchy viewer helped me in identifying the ListView and it's 10 children. I can see the children here, but they just do not display in the emulator. Are there any settings i can check? I checked getVisibility already, are there other properties i can check (viewport, parent settings etc)? I'm really clueless. Regards, Patrick 2009/12/14 Mark Murphy mmur...@commonsware.com Patrick Plaatje wrote: thanx for your amazing fast reply. All your remarks are very valid, but i might have oversimplified my code: Sorry, I took the code listings at face value. Your last remark is interesting though, how can i use the hierarchy viewer? Because when i use lv.getVisibility() it gives me 0 (what as far as i know means it's visible) hierarchyviewer is in the tools/ directory of your SDK. Documentation is here: http://developer.android.com/guide/developing/tools/hierarchy-viewer.html It is very handy for issues like this. Any more thoughts? Off the top of my head, no. I am not really feeling your code organization, so it is unclear to me why your adapter is not being invoked. Sorry! -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 2.8 Available! -- 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+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Met vriendelijke groet, Patrick Plaatje NDC|VBK de uitgevers Sixmastraat 32, 8915 PA Leeuwarden Postbus 394, 8901 BD Leeuwarden T (058) - 284 5044 M (06) - 158 966 34 -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Listview problems
Hi Mark, thanx for the response. Using the wireframe diagram and the visualized views, i found out that the listviews were added, but are laying on top of eachother. I'm not sure why this is happening though or how to correct this. But i'll continue my quest :-) Thanks so much for all the help! Patrick 2009/12/14 Mark Murphy mmur...@commonsware.com Patrick Plaatje wrote: Hi Mark, the hierarchy viewer helped me in identifying the ListView and it's 10 children. I can see the children here, but they just do not display in the emulator. Are there any settings i can check? I checked getVisibility already, are there other properties i can check (viewport, parent settings etc)? I'm really clueless. Are they behind something that is obscuring them? Are they drawn in the right place on the screen, per the wireframe diagram on the right and their x/y/width/height properties? -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _Android Programming Tutorials_ Version 1.0 Available! -- 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+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Met vriendelijke groet, Patrick Plaatje NDC|VBK de uitgevers Sixmastraat 32, 8915 PA Leeuwarden Postbus 394, 8901 BD Leeuwarden T (058) - 284 5044 M (06) - 158 966 34 -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Listview problems
Hi Mark, i've set the minHeight for the view attached to the listview and it seems to be fine now so much trouble for something so small.. What i'm currently experiencing though is that the getView method in my custom adapter is only executed for the items drawn on the screen and other views are loaded when they are within the view port. Is this correct behaviour, because i am experiencing NPE's when i scroll (and a new view is in the listview). Regards, Patrick 2009/12/14 Mark Murphy mmur...@commonsware.com Patrick Plaatje wrote: Hi Mark, the hierarchy viewer helped me in identifying the ListView and it's 10 children. I can see the children here, but they just do not display in the emulator. Are there any settings i can check? I checked getVisibility already, are there other properties i can check (viewport, parent settings etc)? I'm really clueless. Are they behind something that is obscuring them? Are they drawn in the right place on the screen, per the wireframe diagram on the right and their x/y/width/height properties? -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _Android Programming Tutorials_ Version 1.0 Available! -- 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+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Met vriendelijke groet, Patrick Plaatje NDC|VBK de uitgevers Sixmastraat 32, 8915 PA Leeuwarden Postbus 394, 8901 BD Leeuwarden T (058) - 284 5044 M (06) - 158 966 34 -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Listview problems
Hi Mark, thanks a lot. I am indeed using the Holder pattern, and it looks like the Holder object is set to null when the initial listview is loaded. btw. the excerpt helped a lot! Regs, Patrick 2009/12/14 Mark Murphy mmur...@commonsware.com Patrick Plaatje wrote: What i'm currently experiencing though is that the getView method in my custom adapter is only executed for the items drawn on the screen Correct. This is a good thing (imagine 1,000 rows). and other views are loaded when they are within the view port. Likewise correct. because i am experiencing NPE's when i scroll (and a new view is in the listview). You are presumably failing in your getView() implementation, perhaps because you are incorrectly recycling a row or something. Your stack trace (via adb logcat, DDMS, or the DDMS perspective in Eclipse) should help. BTW, here's an excerpt from one of my books that covers a lot of this stuff: http://commonsware.com/Android/excerpt.pdf -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android App Developer Books: http://commonsware.com/books -- 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+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Met vriendelijke groet, Patrick Plaatje NDC|VBK de uitgevers Sixmastraat 32, 8915 PA Leeuwarden Postbus 394, 8901 BD Leeuwarden T (058) - 284 5044 M (06) - 158 966 34 -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] List view with textviews and imageview, best practices
Hi All, i'm developing an application which has an listview. I'm currently creating the list item view dynamically from code (linearlayout, which includes 2 textviews and 1 imageview), but i'd like to use an XML resource for this. I read it isresource intensive when getting this view using findViewById within a loop. I thougth of using a custom adapter for this, but am not sure on how to include lazy loading of the image then. Anyone has some suggestions for this? Regards, Patrick -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Execute method when background task exceeds timespan
Hi all, i'm trying to do the following: 1. Fetching an external resource through a seperate thread; 2. When loaded this thread sends a message to the specified handler 3. This handler executes a method which sets a view to visible All goes well, but now i want to include an extra time, so that when the external resource is not loaded after 5 seconds, the view is going to be displayed anyway. But here's the catch, my handler function goes well, but when i excute the same method outside the handler, it sets the View.visible just fine, but the view just isn;t displaying. the code reads something like: Timer timer = new Timer(); Calendar date = Calendar.getInstance(); date.add(Calendar.SECOND, 1); timer.schedule(new TimerTask() { public void run() { displayArticleList(); }}, date.getTime() ); // fetch the feed in a seperate thread final Handler feedHandler = new Handler(){ @SuppressWarnings(unchecked) public void handleMessage(Message message) { displayArticleList(); } }; ... protected void displayArticleList(){ Log.d(Here, displayArticleList method: + ll_splash.getVisibility() + == + View.GONE); if(!(ll_splash.getVisibility()==View.GONE)){ ll_splash.setVisibility(View.GONE); LinearLayout alc = (LinearLayout) findViewById(R.id.article_list_container); alc.setVisibility(View.VISIBLE); } } -- Regards, Patrick Plaatje -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Nested Table layout not showing
Hi all, in my view i have the need to a somewhat different layout. It needs to display a table within each row a cell for a thumbnail and a cell for displaying a title and a description. The title and description should be displayed on top of eachother, so something like: - | | title| |thumb |description | | | | - In this case i thought i'd use a nested table layout: TableLayout tl = (TableLayout) findViewById(R.id.maintable); int i=0; for (FeedMessage message : f.getMessages()) { // Create a TableRow and give it an ID TableRow tr = new TableRow(this); tr.setId(i); tr.setBackgroundColor(Color.WHITE); tr.setLayoutParams(new TableLayout.LayoutParams( TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.FILL_PARENT)); // setup a new table for the title and the description rows TableLayout table = new TableLayout(this); table.setBackgroundColor(Color.WHITE); table.setShrinkAllColumns(true); table.setLayoutParams(new TableRow.LayoutParams( TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.FILL_PARENT )); // setup the rows for the textviews TableRow titleRow = new TableRow(this); TableRow descriptionRow = new TableRow(this); // construct the views TextView titleView = getTitleView(message); TextView descriptionView = getDescriptionView(message); ImageView thumbView = (ImageView) getThumbView(message); titleRow.addView(titleView); descriptionRow.addView(descriptionView); table.addView(titleRow); table.addView(descriptionRow); tr.addView(table); tl.addView(tr); } I get no exceptions, messages are real objects, but the table just ain't displaying. Any thoughts? Regards, Patrick -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Nested Table layout not showing
Hi there, thanks for the response, but i need to add rows to the table dynamically, so an xm file is not an option i guess. I'm not sure what is wrong with the code below, but i fixed it just now. I'm now using a LinearLayout instead of the nested tabel, and it shows fine. Still strange that the cocde below didn't do what i expected. Regards, Patrick 2009/11/25 jotobjects jotobje...@gmail.com How are you actually inflating this layout in a View? This seems to be a normal table layout. Is there some reason you can't or don't want to use an xml layout file for this? See following example - http://developer.android.com/guide/topics/ui/layout-objects.html#tablelayout On Nov 25, 1:00 am, Patrick Plaatje pplaa...@gmail.com wrote: Hi all, in my view i have the need to a somewhat different layout. It needs to display a table within each row a cell for a thumbnail and a cell for displaying a title and a description. The title and description should be displayed on top of eachother, so something like: - | | title| |thumb |description | | | | - In this case i thought i'd use a nested table layout: TableLayout tl = (TableLayout) findViewById(R.id.maintable); int i=0; for (FeedMessage message : f.getMessages()) { // Create a TableRow and give it an ID TableRow tr = new TableRow(this); tr.setId(i); tr.setBackgroundColor(Color.WHITE); tr.setLayoutParams(new TableLayout.LayoutParams( TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.FILL_PARENT)); // setup a new table for the title and the description rows TableLayout table = new TableLayout(this); table.setBackgroundColor(Color.WHITE); table.setShrinkAllColumns(true); table.setLayoutParams(new TableRow.LayoutParams( TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.FILL_PARENT )); // setup the rows for the textviews TableRow titleRow = new TableRow(this); TableRow descriptionRow = new TableRow(this); // construct the views TextView titleView = getTitleView(message); TextView descriptionView = getDescriptionView(message); ImageView thumbView = (ImageView) getThumbView(message); titleRow.addView(titleView); descriptionRow.addView(descriptionView); table.addView(titleRow); table.addView(descriptionRow); tr.addView(table); tl.addView(tr); } I get no exceptions, messages are real objects, but the table just ain't displaying. Any thoughts? Regards, Patrick -- 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+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Met vriendelijke groet, Patrick Plaatje NDC|VBK de uitgevers Sixmastraat 32, 8915 PA Leeuwarden Postbus 394, 8901 BD Leeuwarden T (058) - 284 5044 M (06) - 158 966 34 -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en