0
所以我創建標題和輸入字段編程在循環中。因爲它代表用下面的代碼,所有的元素都出現揉成在彼此的頂部一起:父對齊程序生成的元素
RelativeLayout mRlayout = (RelativeLayout) findViewById(R.id.checkFieldsLayout);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
Bundle extras = getIntent().getExtras();
List<String> fields = extras.getStringArrayList("checkList");
for (int i = 0; i < fields.size(); i++) {
TextView header = new TextView(this); // Pass it an Activity or Context
header.setText(fields.get(i).toString());
header.setLayoutParams(params);
EditText field = new EditText(this);
field.setLayoutParams(params);
mRlayout.addView(header);
mRlayout.addView(field);
}
如何編程奠定了這些元素,使他們與屏幕的寬度和停靠一個接一個的下面?謝謝!
經過一些修改,這個沒有工作,謝謝! – 2014-10-12 12:38:23