tags:

views:

40

answers:

2

Hai Friends, I am parsing the url to display the contents in it, my requirement i have to display the each content in separate textviews.

For Instance: Let us assume the contents in that url are FootBall, Carom , chess, VolleyBall and so on . I want to display FootBall as a individual textview similarly others. so i cannot declare the textviews in xml what i usually do.

(<TextView  android:text=" " android:layout_width="wrap_content"
                 android:gravity="center_horizontal" android:paddingLeft="7dp" android:layout_height="wrap_content"
               />).

so i planned to create textview via java code This is my parsing code which parse the url contents and store the result in a string array namely san_tagname; depending upon the length of this variable i want to create number of textviews.

     List<Message_category> l_obj_tagname = new ArrayList<Message_category>();
        l_obj_tagname = obj_parse1.parse_tagname();
        System.out.println("l_obj_tagname"+l_obj_tagname.size());
        String[] san = new String[l_obj_tagname.size()];
        Iterator<Message_category> it_id1 = l_obj_tagname.iterator();
        i=-1;
        while (it_id1.hasNext()) {

            i++;
            san[i] = it_id1.next().toString();
            System.out.println("Id="+san[i].toString());
            san_tagname[i]=san[i];
            //vm.setTitle(it.next().toString());

        }
         for(int z=0;z<san_tagname.length;z++)
        {
            //how to create textview here ...............
        }

I am really struggling on this, pls help me regarding on this friends.................

Thanks In Advance Tilsan The Fighter...

A: 
TextView tv = new TextView(context);
tv.setText(myText);
parent.addView(tv, {LayoutParams for parent container type})
hackbod
@Mr.Hackbod: Thanks for Ur replay friend
Tilsan The Fighter
Thank You Very Much for ur help friend i got the Output finally friend
Tilsan The Fighter
A: 

Here is the answer, Parse the Contents from web

//manipulation to parse id
        List<Message_category> l_obj_id = new ArrayList<Message_category>();
        l_obj_id = obj_parse1.parse_id();
        VAL1 = new String[l_obj_id.size()];
        Iterator<Message_category> it_id = l_obj_id.iterator();
        while (it_id.hasNext()) {
            i++;
            VAL1[i] = it_id.next().toString();
            System.out.println("Id="+VAL1[i].toString());
            //vm.setTitle(it.next().toString());
        }

        //manipulation to parse tagname
        List<Message_category> l_obj_tagname = new ArrayList<Message_category>();
        obj_parse1.parse_tagname();
        obj_parse1.storedata();

    san_tagname= new String[obj_parse1.santagname.length];
    for(int k=0;k<obj_parse1.santagname.length;k++)
    {
        san_tagname[k]=ParsingHandler.temptag[k];

        if(san_tagname[k].contains("%20"))
        {
            san_tagname[k]=san_tagname[k].replace("%20"," ");
            System.out.println("San_tagName1"+san_tagname[k]+"S"+k);


        }
        else
        {
            System.out.println("San_tagName2"+san_tagname[k]+"S"+k);
        }
    }


    gal_lay = (LinearLayout) findViewById(R.id.rl_1);
    navagtion_bar= (LinearLayout) findViewById(R.id.san_tag);
    hv = (HorizontalScrollView)findViewById(R.id.gv);

    // This is the Code i needed finally i stirkes with the help of hackbod
    **for(int z=0;z<san_tagname.length;z++)
    {
        TextView san_text[]= new TextView[san_tagname.length];
        san_text[z]=  (TextView) new TextView(this);
        san_text[z].setText(" "+san_tagname[z]+" ");
        san_text[z].setTextSize(15);
        navagtion_bar.addView(san_text[z]);

    }**
Tilsan The Fighter