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 9043251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:41:41+00:00 2026-06-16T10:41:41+00:00

i have to develop android listview using xml parsing., Am getting xml feed from

  • 0

i have to develop android listview using xml parsing.,

Am getting xml feed from mysql server.the product is added day to day activities.

Here i need 3 kind of listview:

1st view:   Category
2nd view:  SubCategory
3rd view:   Product

In fistview have to display Categoryname alone.

From my xml feed 1st view have to display

Categoryname alone

In 2nd view:

Have to display subcategoryname belonging to Categoryname.

In 3nd View:

Have to display Product Name and Price belongs to subcategoryname.

This is my 1st view code:

public class MainActivity extends Activity {
static final String URL =http://api1.sfsfsfsf.com/dev/categories/?fields=&categoryid=3&access_token=bfb787a6e

        static String KEY_CATEGORY = "category";

       static final String KEY_TITLE = "categoryName";
        static final String KEY_SUBCATE = "categoryId";

 ListView lview3;
 LazyAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final ArrayList<HashMap<String, String>> songsList = new ArrayList<HashMap<String, String>>();
    XMLParser parser = new XMLParser();
        String xml = parser.getXmlFromUrl(URL); // getting XML from URL
        Document doc = parser.getDomElement(xml); // getting DOM element

        NodeList nl = doc.getElementsByTagName(KEY_CATEGORY);

        // looping through all song nodes &lt;song&gt;
        for (int i = 0; i < nl.getLength(); i++) {
            // creating new HashMap
            HashMap<String, String> map = new HashMap<String, String>   ();
            Element e = (Element) nl.item(i);


            map.put(KEY_TITLE, parser.getValue(e, KEY_TITLE));
           map.put(KEY_SUBCATE, parser.getValue(e, KEY_SUBCATE));             
        songsList.add(map);
        }
    lview3 = (ListView) findViewById(R.id.listView1);
    adapter = new LazyAdapter(this, songsList);
    lview3.setAdapter(adapter);

    lview3.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
           HashMap<String, String> map = songsList.get(position);
            Intent in = new Intent(
                    MainActivity.this,
                     com.example.androidcartxml.SubCate.class);
            in.putExtra(KEY_TITLE, map.get(KEY_TITLE));
            in.putExtra(KEY_SUBCATE, map.get(KEY_SUBCATE));
               }  


     });

    }

         }

Here i have displayed category list in 1st view.also pass the categoryid from 1st view to 2nd view.

This is my 2nd view code:

       public class SubCate extends Activity {
         String mTitle;

         static final String URL = "http://api1.sfsfsff.com/dev/categories/?fields=&categoryid="+mTitle+"&access_token=bfb787a6e11";
            static String KEY_CATEGORY = "category";

              static final String KEY_TITLE = "categoryName";
             static final String KEY_NAME ="categoryId";
             static final String KEY_SUBCATE = "categoryId";
 ListView lview3;
 ListViewCustomAdapter adapter;
 @Override
 public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.subcate);
    Bundle b = getIntent().getExtras();
    //String s= getIntent().getStringExtra("orderid");
    mTitle = b.getString(KEY_SUBCATE);
    TextView grandtotal = (TextView) findViewById(R.id.subcate);
    grandtotal.setText("Welcome ," + mTitle );
    final ArrayList<HashMap<String, String>> songsList = new ArrayList<HashMap<String, String>>();

   // String key = getIntent().getStringExtra(KEY_TITLE);

        XMLParser parser = new XMLParser();
        String xml = parser.getXmlFromUrl(URL); // getting XML from URL
        Document doc = parser.getDomElement(xml); // getting DOM element

        NodeList nl = doc.getElementsByTagName(KEY_CATEGORY);

        // looping through all song nodes &lt;song&gt;
        for (int i = 0; i < nl.getLength(); i++) {
            // creating new HashMap
            HashMap<String, String> map = new HashMap<String, String>();
            Element e = (Element) nl.item(i);
            // adding each child node to HashMap key =&gt; value

            map.put(KEY_TITLE, parser.getValue(e, KEY_TITLE));
            map.put(KEY_NAME, parser.getValue(e, KEY_NAME));
            songsList.add(map);
        }
    lview3 = (ListView) findViewById(R.id.listView1);
    adapter = new ListViewCustomAdapter(this, songsList);
    lview3.setAdapter(adapter);

    lview3.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            HashMap<String, String> map = songsList.get(position);
            Intent in = new Intent(
                    SubCate.this,
                     com.example.androidcartxml.Catalogue.class);

            in.putExtra(KEY_TITLE, map.get(KEY_TITLE));
            in.putExtra(KEY_NAME, map.get(KEY_NAME));
        //  in.putExtra(KEY_THUMB_URL, map.get(KEY_THUMB_URL));
            //in.putExtra(KEY_PRICE, map.get(KEY_PRICE));
            startActivity(in);
        }  

     });

In 2nd view have displayed categoryid value get it from 1st activity.but i have to mention that id to link means doesn’t getting subcategory list.please give me some solution for these.

FOR EG:

take this is my subcategory link:

[http://api1.sfsfsffsf.com/dev/categories/?fields=&categoryid=10&access_token=bfb787a6e1][1]

means have displayed subcategory list.

Here i have to pass that category id 10(categoryid=10) from first to second and save it i textview.

    mTitle = b.getString(KEY_SUBCATE);
    TextView grandtotal = (TextView) findViewById(R.id.subcate);
       grandtotal.setText("Welcome ," + mTitle );

I have to call these mTitle value on my link means it is not displayed on subcategorylist.please help me.

[http://api1.sfsfsff.com/dev/categories/?fields=&categoryid=”+mTitle+”&access_token=bfb787a6][2]

whats wrong in my code.how can call that categoryid to my url.please give me solution for these.

EDIT:

This is my url:

[http://api1.sfsfsfsf.com/dev/categories/?fields=&categoryid=10&access_token=bfb787a6e][3]

I have mentioned directly categoryid=10 means have disaplyed all product.

But I have to change this url like:

[http://api1.sfsfsf.com/dev/categories/?fields=&categoryid=”+mTitle+”&access_token=bfb787a6e17][4]

Nw i have changed my url like categoryid=”+mTitle+” means not displayed all products.

mTitle value is getting from my pervious activity.

whats wrong in my code.

my mTitle value is 10.i have to wrote the code like means

grandtotal.setText("Welcome ," + mTitle );

its displayed mTitle value successfully.

grandtotal.setText("Welcome ," + URL ); means gave me null value

  • 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-16T10:41:41+00:00Added an answer on June 16, 2026 at 10:41 am

    Here i have called URL first then only declared mTitle value.thats why i have faced problem here.

    Now i got the solution:

    I have declared mTitle first afterthat only have called URL like below.

     mTitle = b.getString(KEY_SUBCATE);
    
     URL = "http://api1.sfsfsffsf.com/dev/categories/?fields=&categoryid=" + mTitle +       "&access_token=bfb787a";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to develop one android application.The app is performs retrieve data from mysql
i have to develop android xml parsing examples. Here i have to get the
Hi i have to develop one android BBC_NEWS_READER application from here Here am getting
I have develop one android application. Here i have to pass the value from
I am using Rhodes to develop android application. I have installed HTTpary gem in
I have develop android application using Android SDK, Eclipse IDE.In that some times showing
I am using eclipse to develop Android apps.I have not found a way to
I'm Dalsam from Korean. 24old I'm using Eclipse java tools, and develop android. I
Is it possible to develop android games and application if we have good knowledge
I am new in Android. I have develop an app. And now want to

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.