Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old December 25th, 2012, 11:23 PM   #1 (permalink)
Member
Thread Author (OP)
 
Join Date: Dec 2011
Location: chennai
Posts: 158
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 0 Times in 0 Posts
Default xml parsing listview in android like category,subcategory

i have to develop android listview using xml parsing., This is my xml feed:http://dev.mercuryminds.com/xctesting/feed.xml

Am getting xml feed from my mysql server.

The product is added day to day.so how can i develop these.

Here i need 3 kind of listview:

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

In 1st view have to display Categoryname alone.


In 2nd view:

have to display subcategoryname belongs to Categoryname.

In 3nd View:

Have to display Product name and price belongs to subcategoryname.

This is my 1st view code:
[HIGH]

public class MainActivity extends Activity {
static final String URL = "http://dev.mercuryminds.com/xctesting/feed.xml";

static String KEY_CATEGORY = "Category";
static final String KEY_TITLE = "Categoryname";

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));

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) {
}

});

}

}
[/HIGH]

How can i develop 2nd view and 3rd view.please give me solution for me..

Advertisements
krishnaveni is offline  
Last edited by krishnaveni; December 27th, 2012 at 04:33 AM.
Reply With Quote
sponsored links
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 04:15 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.