Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我正在尝试制作一个应用程序,可以加载EditText字段中给定的网站。类似于web浏览器。但我在Url.parse方法中遇到错误_Java_Android - Fatal编程技术网

Java 我正在尝试制作一个应用程序,可以加载EditText字段中给定的网站。类似于web浏览器。但我在Url.parse方法中遇到错误

Java 我正在尝试制作一个应用程序,可以加载EditText字段中给定的网站。类似于web浏览器。但我在Url.parse方法中遇到错误,java,android,Java,Android,如果我在Uri.parse()中放置str,该函数就会工作 例如: public class MainActivity extends ActionBarActivity { String str; EditText username; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

如果我在
Uri.parse()
中放置
str
,该函数就会工作

例如:

public class MainActivity extends ActionBarActivity {
    String str;
    EditText username;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        username = (EditText)findViewById(R.id.uname);
        str = username.getText().toString();
    }

    public void goClick(View v){
        Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse(str)); //here instead of str if i use specific website it will work    but for str it wll not work
        startActivity(browserIntent);
    }
}
如果我试图设置
str=http://www.google.co.uk“
,它不起作用

你知道为什么吗?

你只要搬家就行了

str=username.getText().toString()

go中单击(…)

喜欢 具体的网站它会工作,但对于str它不会工作,你能解释多一点吗??
Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.google.co.uk"));
public void goClick(View v){

str = username.getText().toString()

Intent browserIntent = new Intent("android.intent.action.VIEW",Uri.parse(str));

startActivity(browserIntent);

}