开发者

Add array of strings to linear layout

My code is below. I am displaying the details, but not in a proper way. Can you please help me?

TextView tv1=new TextView(this);
tv1.setText("DisplayName:"+开发者_开发技巧strDisplayName);

TextView tv2=new TextView(this);
tv2.setText("Email:"+strEmail);

TextView tv3=new TextView(this);
tv3.setText("FirstName:"+strFirstName);

TextView tv4=new TextView(this);
tv4.setText("LastName:"+strLastName);

TextView tv5=new TextView(this);
tv5.setText("CreatedDate:"+strCreatedDate);

mProfileLayout.addView(tv1, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
mProfileLayout.addView(tv2, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
mProfileLayout.addView(tv3, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
mProfileLayout.addView(tv4, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
mProfileLayout.addView(tv5, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));


Do you have all these TextViews in your xml? If you do then you can access them with

TextView tvX = (TextView)findViewById(R.id.textviewXid);

and then just set the text

tvX.setText(string);

And so you dont have to use mProfileLayout.addView(....);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜