android - Android Studio:预期方法调用(Java)

标签 android android-studio app-store

我是Android Studio的新手,因此在使用此代码时遇到了麻烦;我收到一个错误,通知我应该进行方法调用(TabbedActivity(intent)),但由于现在从未遇到过该操作,因此我不确定该怎么做。

该程序应该在按下按钮时打开google。

谢谢,这是我的代码:

public class TabbedActivity extends AppCompatActivity   {
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_tabbed);

        final ImageButton button = findViewById(R.id.imagebutton1);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Uri uri = Uri.parse("http://google.com");
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                TabbedActivity(intent); ***<--- error!***
        }
    });
}
}

最佳答案

像这样尝试:

 button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Uri uri = Uri.parse("http://google.com");
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                startActivity(intent); ***<--- error!***
        }

关于android - Android Studio:预期方法调用(Java),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49076369/

相关文章:

android - 在应用 XML 属性之前恢复 View 状态

Android Edit Text Some Text Always there 不可编辑

Android webview 空白 - Android 28 SDK

android - 如何使用 Kotlin 同时定位 JVM/Native 和 Android

ios - 向应用商店提交应用程序时出错

android - 在android中获取街道的方向

android - 为什么我的 ImageView 不以编程方式更改其 ScaleType?

ios - 如何向应用程序商店提交阿拉伯语应用程序

xcode - 无效 bundle 错误 - "requires launch storyboard"

android - 错误 :Execution failed for task ':app:transformResourcesWithMergeJavaResForRelease'