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

  • Home
  • SEARCH
  • 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 8686271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:48:09+00:00 2026-06-12T22:48:09+00:00

public class AndroidXMLParsingActivity extends Activity { public int currentPage = 1; public ListView lisView1;

  • 0
public class AndroidXMLParsingActivity extends Activity {

    public int currentPage = 1;
    public ListView lisView1;
    static final String KEY_ITEM = "docdetails";
    static final String KEY_NAME = "heading";
    public Button btnNext;
    public Button btnPre;
    public static String url = "http://dev.taxmann.com/TaxmannService/TaxmannService.asmx/GetNotificationList";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // listView1
        lisView1 = (ListView) findViewById(R.id.listView1);

        // Next
        btnNext = (Button) findViewById(R.id.btnNext);
        // Perform action on click
        btnNext.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                currentPage = currentPage + 1;
                ShowData();
            }
        });

        // Previous
        btnPre = (Button) findViewById(R.id.btnPre);
        // Perform action on click
        btnPre.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                currentPage = currentPage - 1;
                ShowData();
            }
        });

        ShowData();
    }

    public void ShowData() {
        XMLParser parser = new XMLParser();
        String xml = parser.getXmlFromUrl(url); // getting XML



          Document  doc = parser.getDomElement(xml);

        NodeList nl = doc.getElementsByTagName(KEY_ITEM);

        int displayPerPage = 5; // Per Page
        int TotalRows = nl.getLength();
        int indexRowStart = ((displayPerPage * currentPage) - displayPerPage);
        int TotalPage = 0;
        if (TotalRows <= displayPerPage) {
            TotalPage = 1;
        } else if ((TotalRows % displayPerPage) == 0) {
            TotalPage = (TotalRows / displayPerPage);
        } else {
            TotalPage = (TotalRows / displayPerPage) + 1; // 7
            TotalPage = (int) TotalPage; // 7
        }
        int indexRowEnd = displayPerPage * currentPage; // 5
        if (indexRowEnd > TotalRows) {
            indexRowEnd = TotalRows;
        }

        // Disabled Button Next
        if (currentPage >= TotalPage) {
            btnNext.setEnabled(false);
        } else {
            btnNext.setEnabled(true);
        }

        // Disabled Button Previos
        if (currentPage <= 1) {
            btnPre.setEnabled(false);
        } else {
            btnPre.setEnabled(true);
        }

        // Load Data from Index
        int RowID = 1;
        ArrayList<HashMap<String, String>> menuItems = new ArrayList<HashMap<String, String>>();
        HashMap<String, String> map;

        // RowID
        if (currentPage > 1) {
            RowID = (displayPerPage * (currentPage - 1)) + 1;
        }

        for (int i = indexRowStart; i < indexRowEnd; i++) {
            Element e = (Element) nl.item(i);
            // adding each child node to HashMap key => value
            map = new HashMap<String, String>();
            map.put("RowID", String.valueOf(RowID));
            map.put(KEY_NAME, parser.getValue(e, KEY_NAME));

            // adding HashList to ArrayList
            menuItems.add(map);

            RowID = RowID + 1;

        }

        SimpleAdapter sAdap;
        sAdap = new SimpleAdapter(AndroidXMLParsingActivity.this, menuItems,
                R.layout.list_item, new String[] { "RowID", KEY_NAME },
                new int[] { R.id.ColRowID, R.id.ColName });
        lisView1.setAdapter(sAdap);
    }

}

This is My Source code and I want to set ProgressBar this activity is calling from another activity on Button click I want set ProgressBar when data is loading ShowData() function we have use for Parsing Printing,and pagination I tried Much but I am not able to put ProgressBar For loading data please tell me how to implement it.

  • 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-06-12T22:48:10+00:00Added an answer on June 12, 2026 at 10:48 pm

    Try this code, it will work..

    public class AndroidXMLParsingActivity extends Activity {
    
        public int currentPage = 1;
        public ListView lisView1;
        static final String KEY_ITEM = "docdetails";
        static final String KEY_NAME = "heading";
        public Button btnNext;
        public Button btnPre;
        public static String url = "http://dev.taxmann.com/TaxmannService/TaxmannService.asmx/GetNotificationList";
        SimpleAdapter sAdap;
        ProgressDialog progressDialog;
        Activity mActivity;
        ArrayList<HashMap<String, String>> menuItems;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            mActivity = this;
            // listView1
            lisView1 = (ListView) findViewById(R.id.listView1);
    
            // Next
            btnNext = (Button) findViewById(R.id.btnNext);
            // Perform action on click
            btnNext.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    currentPage = currentPage + 1;
                    new backProcess().execute();
                }
            });
    
            // Previous
            btnPre = (Button) findViewById(R.id.btnPre);
            // Perform action on click
            btnPre.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    currentPage = currentPage - 1;
                    new backProcess().execute();
                }
            });
    
            new backProcess().execute();
        }
    
        public void ShowData() {
            XMLParser parser = new XMLParser();
            String xml = parser.getXmlFromUrl(url); // getting XML
    
            Document doc = parser.getDomElement(xml);
    
            NodeList nl = doc.getElementsByTagName(KEY_ITEM);
    
            int displayPerPage = 5; // Per Page
            int TotalRows = nl.getLength();
            int indexRowStart = ((displayPerPage * currentPage) - displayPerPage);
            int TotalPage = 0;
            if (TotalRows <= displayPerPage) {
                TotalPage = 1;
            } else if ((TotalRows % displayPerPage) == 0) {
                TotalPage = (TotalRows / displayPerPage);
            } else {
                TotalPage = (TotalRows / displayPerPage) + 1; // 7
                TotalPage = (int) TotalPage; // 7
            }
            int indexRowEnd = displayPerPage * currentPage; // 5
            if (indexRowEnd > TotalRows) {
                indexRowEnd = TotalRows;
            }
    
            // Disabled Button Next
            if (currentPage >= TotalPage) {
                btnNext.setEnabled(false);
            } else {
                btnNext.setEnabled(true);
            }
    
            // Disabled Button Previos
            if (currentPage <= 1) {
                btnPre.setEnabled(false);
            } else {
                btnPre.setEnabled(true);
            }
    
            // Load Data from Index
            int RowID = 1;
            menuItems = new ArrayList<HashMap<String, String>>();
            HashMap<String, String> map;
    
            // RowID
            if (currentPage > 1) {
                RowID = (displayPerPage * (currentPage - 1)) + 1;
            }
    
            for (int i = indexRowStart; i < indexRowEnd; i++) {
                Element e = (Element) nl.item(i);
                // adding each child node to HashMap key => value
                map = new HashMap<String, String>();
                map.put("RowID", String.valueOf(RowID));
                map.put(KEY_NAME, parser.getValue(e, KEY_NAME));
    
                // adding HashList to ArrayList
                menuItems.add(map);
    
                RowID = RowID + 1;
    
            }
    
        }
    
        public class backProcess extends AsyncTask<Void, Void, Void> {
    
            @Override
            protected void onPostExecute(Void result) {
                if (progressDialog != null)
                    progressDialog.dismiss();
                sAdap = new SimpleAdapter(AndroidXMLParsingActivity.this,
                        menuItems, R.layout.list_item, new String[] { "RowID",
                                KEY_NAME },
                        new int[] { R.id.ColRowID, R.id.ColName });
                lisView1.setAdapter(sAdap);
                super.onPostExecute(result);
            }
    
            @Override
            protected void onPreExecute() {
                progressDialog = ProgressDialog.show(mActivity, "Wait",
                        "Loading...");
                super.onPreExecute();
            }
    
            @Override
            protected Void doInBackground(Void... params) {
                ShowData();
                return null;
            }
    
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class SaveData extends Activity implements OnClickListener { private DataManipulator dh; static final int
public class PackageTabActivity extends ListActivity{ HashMap<String,Object> hm ; ArrayList<HashMap<String,Object>> applistwithicon ; private static final
public class MCQSample extends Activity implements OnClickListener{ TextView title; String gotBread; RadioGroup AnswerRG; int
public class BobDatabase extends SQLiteOpenHelper{ private static final String DATABASE_NAME = bob.db; private static
public class Sample2 extends Activity { private SampleView sView; private static int displayWidth =
public class A { private A(int param1, String param2) {} public static A createFromCursor(Cursor
public class demo { public static void main(String[] args) { for(int k = 2029;
public class Base{ protected String str; public static final Base ERROR = new Base(error);
public class DBAdapter { public static final String COLUMN_ID = ID; public static final
public class Encryption { private static final int[] encrypt = {2, 9, 3, 4,

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.