有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在web浏览器中打开一个URL,并从回收器适配器获取该URL

单击后,我无法打开web浏览器从回收器适配器获取url。 我用上下文初始化了适配器,但应用程序仍将崩溃

public class recyclerAdapter extends RecyclerView.Adapter<recyclerAdapter.ViewHolder> {

private ArrayList<Item> mItems;
    private Context mContext;
    private LayoutInflater mLayoutInflater;

    public RecyclerAdapter(ArrayList<Item> items, Context context) {
        mItems = items;
        mContext = context;
        mLayoutInflater = LayoutInflater.from(mContext);
    }

//other things....

public class ViewHolder extends RecyclerView.ViewHolder{
        public final ImageView mImageView;

        public TopFreeStoreViewHolder(@NonNull View itemView) {
            super(itemView);
            mImageView = itemView.findViewById(R.id.imageViewItem);
            mImageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    String Url = www.google.com;
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setData(Uri.parse(Url));
                    mContext.startActivity(intent);
                }
            });
        }
    }
}

错误:安卓。所容纳之物ActivityNotFoundException:未找到可处理意图的活动{act=安卓.Intent.action.VIEW dat=www.google.com.}


共 (0) 个答案