我刚刚尝试创建一个mems生成器应用程序,是的,我一直在关注新的bostons,并在那个buckey中使用2个片段创建它们,在这里我只是想做在一个单一的主要活动,但我只是不知道如何从编辑文本字段中检索文本并将文本视图的文本设置为它,我知道它的一个新手问题,但我仍然不知道如何代码,所以请帮助.. !!!如何在TextView中显示EditText字段文本
我刚刚进口了一些小工具,意见等,并做了一些修改上创建功能,我上创建功能是 -
public class MainActivity extends AppCompatActivity {
public static EditText topText;
public static EditText bottomtext;
public static TextView top;
public static TextView bottom;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
topText = (EditText) findViewById(R.id.topedit);
bottomtext = (EditText) findViewById(R.id.bottomedit);
top = (TextView) findViewById(R.id.top);
bottom = (TextView) findViewById(R.id.bottom);
Button myButton = (Button) findViewById(R.id.button);
myButton.setOnClickListener(
new Button.OnClickListener() {
public void onClick(View V) {
top.setText((CharSequence) topText);
bottom.setText((CharSequence) bottomtext);
}
}
);
}
来到之前实现阅读还机器人的完整文档,你会发现在文档中几乎所有的东西。您可以参考http://developer.android.com – Aakash
感谢他只是一些小的修改,即颠倒null和topText.getText()和底部也一样 - if(null!= topText.getText( )){ top.setText(topText.getText()。toString()); (null!= bottomtext.getText()){ } bottom.setText(bottomtext.getText()。toString()); } –
高兴地帮助,请标记为正确的,如果我的回答是有帮助的 – Aakash