동적보기를 만드는 데이 클래스를 사용하십시오. 도움이 될 수 있습니다.
public class MainActivity extends Activity {
LinearLayout l1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
l1=(LinearLayout)findViewById(R.id.linear_layout);
LinearLayout layout=new LinearLayout(this);
layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
layout.setOrientation(LinearLayout.HORIZONTAL);
TextView text1=new TextView(this);
text1.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
text1.setText("Enter any two colors");
EditText edt1=new EditText(this);
edt1.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
edt1.setHint("COLOR1");
TextView text2=new TextView(this);
text2.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
text2.setText("and");
EditText edt2=new EditText(this);
edt2.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
edt2.setHint("COLOR2");
layout.addView(text1);
layout.addView(edt1);
layout.addView(text2);
layout.addView(edt2);
l1.addView(layout);
}
}
답변을 게시 해 주셔서 감사합니다. mayuri. 하지만 내가 직면 한 유일한 문제는 질문 길이가 길다는 것입니다. 원하는 두 가지 색상을 입력하십시오. 다음 줄에 표시되는 것이 아니라 손질이됩니다. –