display the article belonging category on next row horixontal listview in android like BBC News Read

Discussion in 'Application Development' started by krishnaveni, Feb 4, 2013.

  1. krishnaveni

    krishnaveni Well-Known Member

    Dec 16, 2011
    I have to develop one android listview application like BBC news Reader.

    This is my xml feed:

    Here i have to display Category name on first page like horizontal listview.
    I have to display Article title belongs to category name on same page below the category name horizontal listview.

    For Eg:

    Here i have to click any category on first listview means its display on article title (horizontal listview) belonging to that category name below the category name horizontal listview.

    How can i do ??? please help me.

    This is code for category name is displayed on first row horizontal listview.

    public class MainActivity extends Activity {

    String URL;
    static String KEY_CATEGORY = "Categories";
    ArrayList<HashMap<String, String>> songsList;
    static final String KEY_PNAME = "Category";
    static final String KEY_PRICE = "article";
    static final String KEY_THUMB_URL = "thumb_image";

    ListAdapter adapter;

    /** Called when the activity is first created. */
    protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    songsList = new ArrayList<HashMap<String, String>>();
    HorizontalListView list = (HorizontalListView) findViewById(R.id.listView1);
    adapter = new ListAdapter(this, songsList);


    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_PNAME);
    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_PNAME,((Element)nl.item(i)).getAttribute("name"));
    // map.put(KEY_PNAME, parser.getValue(e, (KEY_PNAME)));
    // map.put( KEY_PRICE,((Element)nl.item(i)).getAttribute("title"));

    map.put(KEY_PRICE, parser.getValue(e, KEY_PRICE));
    map.put(KEY_THUMB_URL, parser.getValue(e, KEY_THUMB_URL));

    // adding HashList to ArrayList

    // Click event for single list row
    list.setOnItemClickListener(new OnItemClickListener() {

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


    Here i have to run the app means display the category name on first row horizontal listview.how can i display the article title is belonging to category on next row horizontal listview...how can i wrote the condition for these.how can i develop the code???? please give me some idea to develop ????please give me solution...


Share This Page