开发者

Android RSS reader GUI problem

开发者 https://www.devze.com 2023-03-27 07:30 出处:网络
I have an RSS reader which display the titles of a RSS feeds in a list. on clicking the title the 开发者_运维百科main source page of the title should open...

I have an RSS reader which display the titles of a RSS feeds in a list. on clicking the title the 开发者_运维百科main source page of the title should open... the following code works fine for a small list but if i have a long list which contains feeds from more than one website the application stops and i have to force close it. can anybody help me to fix it please.

@Override
        protected void onListItemClick(ListView l, View v, int position, long id) {
            super.onListItemClick(l, v, position, id);
            Intent viewMessage = new Intent(Intent.ACTION_VIEW, 
                    Uri.parse(messages.get(position).getLink().toExternalForm()));
            this.startActivity(viewMessage);
        }


It's possible, depending on how many pages you're parsing, you'll want to start an asynchronous task. Basically you'll start a new thread separate from your UI thread so you won't have to force close the application. Read more about asynchronous tasks here:

http://developer.android.com/reference/android/os/AsyncTask.html

Also - if you implement error checking you'll be able to continue to run the application if you do get an exception from parsing.

0

精彩评论

暂无评论...
验证码 换一张
取 消