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


  1. krishnaveni

    krishnaveni Well-Known Member

    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.

    [HIGH]
    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. */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    songsList = new ArrayList<HashMap<String, String>>();
    HorizontalListView list = (HorizontalListView) findViewById(R.id.listView1);
    adapter = new ListAdapter(this, songsList);

    list.setAdapter(adapter);
    URL="http://webservices/xctesting/feed.xml";

    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
    songsList.add(map);
    }

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

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

    });
    [/HIGH]


    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...

    Advertisement

Share This Page