进口值到另一个类 [英] importing value to another class
本文介绍了进口值到另一个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
btnRegister.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
String name = inputFullName.getText().toString();
String email = inputEmail.getText().toString();
String password = inputPassword.getText().toString();
if (!name.isEmpty() && !email.isEmpty() && !password.isEmpty()) {
registerUser(name, email, password);
} else {
Toast.makeText(getApplicationContext(),
"Please enter your details!", Toast.LENGTH_LONG)
.show();
}
return name; //<-here is the error
}
我要导入名到另一个类..我该怎么做呢?
i want to import "name" to another class.. How Can i do this?
推荐答案
我猜你想要的值发送到另一个活动,对不对?那么你应该使用意图。
I guess you want to send the value to another activity, right? Then you should use intents.
在您的活动:
Intent intent = new Intent();
intent.putExtra("name", name);
startActivity(intent);
在哪里你想要得到的价值活动:
In the activity where you want to get the value:
Bundle extras = getIntent().getExtras();
if (extras != null) {
String data = extras.getString("name");
这篇关于进口值到另一个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文