View Single Post
Old December 25th, 2012, 11:23 PM   #1 (permalink)
Thread Author (OP)
Join Date: Dec 2011
Location: chennai
Posts: 158
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:

Am getting xml feed from my mysql server.

The product is added day to 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:

public class MainActivity extends Activity {
static final String URL = "";

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

ListView lview3;
LazyAdapter adapter;
public void onCreate(Bundle savedInstanceState) {
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));

lview3 = (ListView) findViewById(;
adapter = new LazyAdapter(this, songsList);

lview3.setOnItemClickListener(new OnItemClickListener() {

public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {




How can i develop 2nd view and 3rd view.please give me solution for me..
krishnaveni is offline  
Last edited by krishnaveni; December 27th, 2012 at 04:33 AM.
Reply With Quote