单击后,我无法打开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);
}
});
}
}
}
错误:android.content.activitynotfoundexception:找不到处理intent的活动{act=android.intent.action.view dat=www.google.com. }
1条答案
按热度按时间fkvaft9z1#
您使用的url格式错误。试试这个,