怎么使用 LinearLayout的 addview方法添加多个view呢
添加一个是可以显示的,添加多个也只显示一个发现也没有被覆盖,先添加到有,后添加到看不到privatevoidShowSmsInfosEx(String[]vals){Li...
添加一个是可以显示的,添加多个也只显示一个
发现也没有被覆盖,先添加到有,后添加到看不到
private void ShowSmsInfosEx(String[] vals){
LinearLayout rl = (LinearLayout)findViewById(R.id.RelativeLayout02);
rl.setOrientation(LinearLayout.HORIZONTAL);
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
ArrayList<View> views = new ArrayList<View>();
int j = 0;
for(int i = vals.length - 1; i >= 0 ; --i){
TextView textView = new TextView(this);
textView.setWidth(dm.widthPixels - 20);
textView.setSingleLine(false);
//textView.setBackgroundDrawable(getResources().getDrawable(
// R.drawable.popblack));
textView.setText(vals[i]);
views.add(textView);
//rl.addView(textView, ++j);
rl.addView(textView, new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,RelativeLayout.LayoutParams.WRAP_CONTENT));
}
} 展开
发现也没有被覆盖,先添加到有,后添加到看不到
private void ShowSmsInfosEx(String[] vals){
LinearLayout rl = (LinearLayout)findViewById(R.id.RelativeLayout02);
rl.setOrientation(LinearLayout.HORIZONTAL);
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
ArrayList<View> views = new ArrayList<View>();
int j = 0;
for(int i = vals.length - 1; i >= 0 ; --i){
TextView textView = new TextView(this);
textView.setWidth(dm.widthPixels - 20);
textView.setSingleLine(false);
//textView.setBackgroundDrawable(getResources().getDrawable(
// R.drawable.popblack));
textView.setText(vals[i]);
views.add(textView);
//rl.addView(textView, ++j);
rl.addView(textView, new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,RelativeLayout.LayoutParams.WRAP_CONTENT));
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询