0
我需要将textview
和imageview
设置为linearlayout
。文本的内容是一个字符串array.I无法得到在布局中的文字,其他一切都是精细 我的代码是:将textview和imageview添加到在android中动态创建的线性布局
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
TextView topicText = new TextView(this);
LinearLayout textLinear = new LinearLayout(this);
textLinear.setOrientation(LinearLayout.HORIZONTAL);
textLinear.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.action_background_item));
topicText.setId(i);
topicText.setTextSize((float) 19.2);
topicText.setText((CharSequence) mStringArray[i]);
topicText.setTextColor(000000);
topicText.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.icon,0);
topicText.setLayoutParams(lp);
topicText.setTag(i);
textLinear.addView(topicText);
this.topLayout.addView(textLinear);
我添加了linearlayout到父 – info
所以你的问题是如何从资源中的字符串数组获取值? – NickF
是啊需要显示该线性布局创建的文本和图像,但不幸的是文本不显示:( – info