Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7664553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:20:08+00:00 2026-05-31T14:20:08+00:00

I wrote some app that using lauot- procce bar and AsyncTask to do some

  • 0

I wrote some app that using lauot- procce bar and AsyncTask to do some work with xml and display it to user.
I want to dismess the proccess bar after back proccess will finish
but have some problem with my code

the errors:

FATAL EXCEPTION: AsyncTask #2
 03-17 11:25:29.559: E/AndroidRuntime(31114): java.lang.RuntimeException: An error           while executing doInBackground()
  03-17 11:25:29.559: E/AndroidRuntime(31114):  at          android.os.AsyncTask$3.done(AsyncTask.java:200)
  03-17 11:25:29.559: E/AndroidRuntime(31114):  at   java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
  03-17 11:25:29.559: E/AndroidRuntime(31114):  at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
  03-17 11:25:29.559: E/AndroidRuntime(31114):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
 03-17 11:25:29.559: E/AndroidRuntime(31114):   at java.util.concurrent.FutureTask.run(FutureTask.java:138)
 03-17 11:25:29.559: E/AndroidRuntime(31114):   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
 03-17 11:25:29.559: E/AndroidRuntime(31114):   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
 03-17 11:25:29.559: E/AndroidRuntime(31114):   at java.lang.Thread.run(Thread.java:1019)
03-17 11:25:29.559: E/AndroidRuntime(31114): Caused by: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
03-17 11:25:29.559: E/AndroidRuntime(31114):    at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
0    3-17 11:25:29.559: E/AndroidRuntime(31114):    at java.util.ArrayList.get(ArrayList.java:311)
   03-17 11:25:29.559: E/AndroidRuntime(31114):     at com.example.News.NewsActivity$GetDataTask.doInBackground(NewsActivity.java:67)
  03-17 11:25:29.559: E/AndroidRuntime(31114):  at 

my code is:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.progdailog);
mContext = this;
    new GetDataTask().execute();
}
 protected void onPostExecute(Integer result) {

        listAdapter = new CustomListAdapter(mContext, R.layout.list_item,
                ListNews);
        ListView lv = ((ListActivity) mContext).getListView();
        lv.setAdapter(listAdapter); // on test

        lv.setTextFilterEnabled(true);

        lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                if (position != 0) {

                    // When clicked, show a toast with the TextView text
                    String s = ReadXML.hadashotListItems.get(position - 1).link;

                    Intent intent = new Intent(NewsActivity.this,
                            WebActivity.class);
                    intent.putExtra("url", s);

                    startActivity(intent);

                }
            }

            public void onScrollStateChanged(final AbsListView view,
                    final int scrollState) {
                if (scrollState == 0)
                    listAdapter.notifyDataSetChanged();
            }
        });

        //progDailog.dismiss();
        super.onPostExecute(result);

    }

}

the line 67 is in code:

 protected Integer doInBackground(Void... params) {
        try {
            ReadXML = new ReadXMLFile(mContext, getIntent().getExtras()
                    .getString("urlXml"));

            ListNews.add("NEWS");
            if (checkDate(ReadXML.hadashotListItems.get(0).pubDate,ReadXML.hadashotListItems.get(1).pubDate))
            for (int i = 0; i < ReadXML.hadashotListItems.size(); i++) {

                ListNews.add(ReadXML.hadashotListItems.get(i).title + "\n"
                        + ReadXML.hadashotListItems.get(i).pubDate);
            }
            else
                for (int i = ReadXML.hadashotListItems.size()-1; i >=0; i--) {

                    ListNews.add(ReadXML.hadashotListItems.get(i).title + "\n"
                            +     ReadXML.hadashotListItems.get(i).pubDate);
                }
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (java.text.ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return 1;
            }  

I think something wrong with view. hop you can help change the code that it will work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:20:10+00:00Added an answer on May 31, 2026 at 2:20 pm

    There is an IndexOutOfBoundsException on line 67 of NewsActivity.java.

    IndexOutOfBoundsException: Invalid index 0, size is 0
    

    You are trying to access index 0 when there are no elements. I don’t think you have posted that code, so look for that line and fix the incorrect index access.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a simple Sinatra app that generate an image using rmagick from some
I wrote an app that uses XPath to query some XML config files. When
I wrote a multi user app in c# some time age using SQL Server
I am porting an app that I originally wrote using the accelerometer for IOS
I wrote an app that plots my position on the google map API using
We have a database app that we're beginning to write some new systems for
I wrote some code with a lot of recursion, that takes quite a bit
I wrote some small apps using .NET 3.5 but now I am stuck with
I wrote some naive code(in the sense that it's synchronous calls) for a tableview
I wrote an app that allows users to enter in a date on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.