Adding new rows dynamically to table with loop - android
I am trying to do rss reader for android. I take datas from webservice and put into arraylist. Then i take that arraylist in activity class..I want to create table rows and textviews which count is equal to arraylist size.There are no problems here.But when i execute the application all text views gives same result(last item of arraylist).All arraylist items are different.
I expect that result

> news[1]<br>
> news[2]<br>
> news[3] ....

but i get
>news[20]<br>
>news[20]<br>
>news[20]<br>

what is wrong with that i dont get it. I try the create textview and row instances out of the for loop but i get ".IllegalStateException:the specified child already has a parent" exception.
I have a news pojo and Here is my code.

   

    protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.guncel);
		WebService ws = new WebService();
		TableLayout tb = (TableLayout) findViewById(R.id.tbl1);
		TextView txtview = new TextView(this);
		news news1 = null;
		List<news> newslist;
		URL serviceURL;
		try {
			serviceURL = new URL(
					"http://rss.hurriyet.com.tr/rss.aspx?sectionId=1");
			newslist = ws.getList(serviceURL);
			for (news new1 : newslist) {
				TableRow row = new TableRow(this);
				row.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
						LayoutParams.WRAP_CONTENT));
				news1 = (news) newslist.get(i);
				txtview.setText(new1.getTitle());
				System.out.println(new1.getTitle());
				row.addView(txtview);
				tb.addView(row);
			}
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}

	}


Adding new rows dynamically to table with loop - android
===

I am trying to do rss reader for android. I take datas from webservice and put into arraylist. Then i take that arraylist in activity class..I want to create table rows and textviews which count is equal to arraylist size.There are no problems here.But when i execute the application all text views gives same result(last item of arraylist).All arraylist items are different.
I expect that result

> news[1]<br>
> news[2]<br>
> news[3] ....

but i get
>news[20]<br>
>news[20]<br>
>news[20]<br>

what is wrong with that i dont get it. I try the create textview and row instances out of the for loop but i get ".IllegalStateException:the specified child already has a parent" exception.
I have a news pojo and Here is my code.

   

    protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.guncel);
		WebService ws = new WebService();
		TableLayout tb = (TableLayout) findViewById(R.id.tbl1);
		TextView txtview = new TextView(this);
		news news1 = null;
		List<news> newslist;
		URL serviceURL;
		try {
			serviceURL = new URL(
					"http://rss.hurriyet.com.tr/rss.aspx?sectionId=1");
			newslist = ws.getList(serviceURL);
			for (news new1 : newslist) {
				TableRow row = new TableRow(this);
				row.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
						LayoutParams.WRAP_CONTENT));
				news1 = (news) newslist.get(i);
				txtview.setText(new1.getTitle());
				System.out.println(new1.getTitle());
				row.addView(txtview);
				tb.addView(row);
			}
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}

	}

