textview editetxt
textview edittext
textview edittext按钮
LinearLayout lLayout = (LinearLayout)findViewById(R.id.linearLayout);
TextView textViewName = new TextView (MainActivity.this);
textViewName .setText("Name:");
Edittext editTextName= new Edittext (MainActivity.this);
lLayout.addView(textViewName );
lLayout.addView(editTextName);
答案 0 :(得分:0)
您可以在lLayout(垂直)内创建另一个LinearLayout hLayout,并使用
将此新布局的方向设置为水平hLayout.setOrientation(LinearLayout.Horizontal);
将其添加到llayout
lLayout.addView(hlayout);
现在将textview nad edittext放在hlayout中。
答案 1 :(得分:0)
package manish.example.testproject;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
public class MainActivity extends Activity {
int m = 3; // here write number of view want show
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout main = new LinearLayout(this);
main.setOrientation(LinearLayout.VERTICAL);
for (int k = 0; k < m; k++) {
LinearLayout li = new LinearLayout(this);
li.setOrientation(LinearLayout.HORIZONTAL);
TextView t = new TextView(this);
t.setText("Name : ");
EditText e = new EditText(this);
li.addView(t);
li.addView(e);
main.addView(li);
}
setContentView(main);
}
}
答案 2 :(得分:0)
我完全不明白,但根据我的理解,我正在编写我的代码
LinearLayout lLayout = (LinearLayout)findViewById(R.id.layout1);
LinearLayout Layout2 = new LinearLayout(this);
TextView textViewName = new TextView (MainActivity.this);
textViewName .setText("Name:");
EditText editTextName= new EditText (MainActivity.this);
lLayout.setOrientation(LinearLayout.VERTICAL);
lLayout.addView(Layout2);
Layout2.setOrientation(LinearLayout.HORIZONTAL);
Layout2.addView(textViewName );
Layout2.addView(editTextName);