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:
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 <song>
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) {
}
});
}
}How can i develop 2nd view and 3rd view.please give me solution for me..