Java 在chrome onClick中打开书签
我制作了一个应用程序,用户可以使用onClick事件访问chrome中的书签。然而,当我点击我的按钮时,我得到一个运行时提示Java 在chrome onClick中打开书签,java,android,google-chrome,android-studio,Java,Android,Google Chrome,Android Studio,我制作了一个应用程序,用户可以使用onClick事件访问chrome中的书签。然而,当我点击我的按钮时,我得到一个运行时提示 PID:12500 java.lang.IllegalStateException:无法为android执行方法:onClick 原因:java.lang.reflect 我不知道这里有什么问题。我也试过了 Uri uri = Uri.parse("content://com.android.chrome.browser/bookmarks"); 我的代码是fallo
PID:12500 java.lang.IllegalStateException:无法为android执行方法:onClick
原因:java.lang.reflect
我不知道这里有什么问题。我也试过了
Uri uri = Uri.parse("content://com.android.chrome.browser/bookmarks");
我的代码是fallows
public void onClickbtnSavedArticles(View view) {
Uri uri = Uri.parse("chrome://bookmarks/"); // missing 'http://' will cause crashed
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
xml
听起来像是您在按钮的android:onClick
属性中指定了一个在您的活动中不存在的方法。@BadCash我添加了我的xml,您可以看到我的android:onClick=“onClickbtnSavedArticles”
确实存在
<LinearLayout
android:id="@+id/lstAddBudget"
android:layout_width="match_parent"
android:layout_height="62dp"
android:layout_below="@+id/list_item"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:gravity="center_vertical"
android:background="#555454"
android:layout_marginTop="20dp"
>
<ImageView
android:layout_width="33dp"
android:layout_height="match_parent"
android:layout_marginRight="15dp"
android:src="@drawable/savearticle" />
<TextView
android:id="@+id/addBudget"
android:layout_width="0dp"
android:layout_weight="0.58"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="#ffffff"
android:layout_gravity="center"
android:text="Saved Articles"
/>
<ImageView
android:id="@+id/savedArticles"
android:layout_width="51dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:src="@drawable/nextarrow"
android:onClick="onClickbtnSavedArticles"
/>
</LinearLayout>