textview
및 imageview
을 linearlayout
에 배치해야합니다. 텍스트의 내용은 문자열 array.I 레이아웃의 텍스트를 얻을 수있다, 다른 모든 괜찮 내 코드는 다음과 같습니다 당신은 정말있는 LinearLayout에 텍스트 뷰를 추가 한android에 동적으로 생성 된 선형 레이아웃에 textview 및 imageview 추가
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