Java Android noobie,使用表单创建url
我对Java和Android已经了如指掌。通常我用Python编写代码,它越来越容易 Java从不允许我做任何事情,或者只允许我使用我不知道的独特方法: 所以唯一有效的代码是复制粘贴,很难自定义 所以,我有一个简单的可编辑文本和一个按钮,当我点击它时,我会转到一个url。该按钮起作用:我可以打开我的webview。 但我想用editText创建url,但我不能: 请注意:Java Android noobie,使用表单创建url,java,android,android-edittext,Java,Android,Android Edittext,我对Java和Android已经了如指掌。通常我用Python编写代码,它越来越容易 Java从不允许我做任何事情,或者只允许我使用我不知道的独特方法: 所以唯一有效的代码是复制粘贴,很难自定义 所以,我有一个简单的可编辑文本和一个按钮,当我点击它时,我会转到一个url。该按钮起作用:我可以打开我的webview。 但我想用editText创建url,但我不能: 请注意: public void onCreate(Bundle savedInstanceState) { super.on
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Add Click listeners for all buttons
final EditText Login = (EditText) findViewById(R.id.entry);
View firstButton = findViewById(R.id.ok);
firstButton.setOnClickListener(this);
}
public void onClick(View v) {
switch(v.getId()){
case R.id.ok:
Intent j = new Intent(this, Webscreen.class);
j.putExtra(com.tatai.froyo.Webscreen.URL,
"http://192.168.1.12/index2.php");
startActivity(j);
break;
}
那么,如何让登录edittext使url像
... 使用登录编辑文本获取toto may的位置
无法在onclick上读取全局变量,我迷路了!:
我在onclick listner上查到:
字符串logDetail=Login.getText.toString;
但它看不到登录,它退出了!:未声明的代码,请尝试以下操作
public void onClick(View v)
{
switch(v.getId())
{
case R.id.ok:
String logDetail = Login.getText().toString();
Intent j = new Intent(this, Webscreen.class);
j.putExtra(com.tatai.froyo.Webscreen.URL,"http://192.168.1.12/index2.php?log="+logDetail);
startActivity(j);
break;
}
编辑:
Login.getText.toString会让你开始的。我想对象不适合我的大脑。。。这些代码被其他代码隔离得太多,很难与对象进行通信。我更喜欢独特的集中和线性代码!谢谢你的帮助。我试过了,但它说:登录未声明看看我编辑的答案。您应该以这种方式声明edittext,这样您就不会出错。它可以工作!非常感谢,我不知道我们可以这么做:对不起,我没有足够的声誉给你打分。
EditText Login;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Add Click listeners for all buttons
Login = (EditText) findViewById(R.id.entry);
View firstButton = findViewById(R.id.ok);
firstButton.setOnClickListener(this);
}
public void onClick(View v)
{
switch(v.getId())
{
case R.id.ok:
String logDetail = Login.getText().toString();
Intent j = new Intent(this, Webscreen.class);
j.putExtra(com.tatai.froyo.Webscreen.URL,"http://192.168.1.12/index2.php?log="+logDetail);
startActivity(j);
break;
}