80,472
社区成员




int screenwidth = getWindowManager().getDefaultDisplay().getWidth();
word_detail = (LinearLayout) findViewById(R.id.word_detail);
int beginindex = 0;
LinearLayout layout = null;
String a;
int width = 0;
boolean donew = false;
for (int i = 0; i < detail.length(); i++) {
if (donew || i == 0) {
donew = false;
layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.HORIZONTAL);
}
a = detail.substring(beginindex, beginindex + 1);
beginindex++;
if (!a.equals("_")) {
TextView textView = new TextView(this);
textView.setText(a);
textView.setTextSize(15);
layout.addView(textView);
Log.e("text", a);
width += 15;
} else {
EditText editText = new EditText(this);
editText.setWidth(200);
layout.addView(editText);
Log.e("edit", "__");
width += 40;
}
if (width >= screenwidth-800) {
word_detail.addView(layout);
width = 0;
donew = true;
}
}
}