精华内容
下载资源
问答
  • ssh 登录出现Are you sure you want to continue connecting (yes/no)?解决方法 1. 可以使用ssh -o 的参数进行设置 例如: ssh-o StrictHostKeyChecking=noroot@192.168.111.22 2. 修改/etc/ssh/ssh_config 将其中的...

    如题中的问题修复:

    修改文件 /etc/ansible/ansible.cfg 中的:

    host_key_checking = False

    注:如果文件 /etc/ansible/ansible.cfg 不存在则自己创建这个文件,文件内容参考:

    # config file for ansible -- https://ansible.com/
    # ===============================================
    
    # nearly all parameters can be overridden in ansible-playbook
    # or with command line flags. ansible will read ANSIBLE_CONFIG,
    # ansible.cfg in the current working directory, .ansible.cfg in
    # the home directory or /etc/ansible/ansible.cfg, whichever it
    # finds first
    
    [defaults]
    
    # some basic default values...
    
    #inventory      = /etc/ansible/hosts
    #library        = /usr/share/my_modules/
    #module_utils   = /usr/share/my_module_utils/
    #remote_tmp     = ~/.ansible/tmp
    #local_tmp      = ~/.ansible/tmp
    #plugin_filters_cfg = /etc/ansible/plugin_filters.yml
    #forks          = 5
    #poll_interval  = 15
    #sudo_user      = root
    #ask_sudo_pass = True
    #ask_pass      = True
    #transport      = smart
    #remote_port    = 22
    #module_lang    = C
    #module_set_locale = False
    
    # plays will gather facts by default, which contain information about
    # the remote system.
    #
    # smart - gather by default, but don't regather if already gathered
    # implicit - gather by default, turn off with gather_facts: False
    # explicit - do not gather by default, must say gather_facts: True
    #gathering = implicit
    
    # This only affects the gathering done by a play's gather_facts directive,
    # by default gathering retrieves all facts subsets
    # all - gather all subsets
    # network - gather min and network facts
    # hardware - gather hardware facts (longest facts to retrieve)
    # virtual - gather min and virtual facts
    # facter - import facts from facter
    # ohai - import facts from ohai
    # You can combine them using comma (ex: network,virtual)
    # You can negate them using ! (ex: !hardware,!facter,!ohai)
    # A minimal set of facts is always gathered.
    #gather_subset = all
    
    # some hardware related facts are collected
    # with a maximum timeout of 10 seconds. This
    # option lets you increase or decrease that
    # timeout to something more suitable for the
    # environment.
    # gather_timeout = 10
    
    # Ansible facts are available inside the ansible_facts.* dictionary
    # namespace. This setting maintains the behaviour which was the default prior
    # to 2.5, duplicating these variables into the main namespace, each with a
    # prefix of 'ansible_'.
    # This variable is set to True by default for backwards compatibility. It
    # will be changed to a default of 'False' in a future release.
    # ansible_facts.
    # inject_facts_as_vars = True
    
    # additional paths to search for roles in, colon separated
    #roles_path    = /etc/ansible/roles
    
    # uncomment this to disable SSH key host checking
    host_key_checking = False
    
    # change the default callback, you can only have one 'stdout' type  enabled at a time.
    #stdout_callback = skippy
    
    
    ## Ansible ships with some plugins that require whitelisting,
    ## this is done to avoid running all of a type by default.
    ## These setting lists those that you want enabled for your system.
    ## Custom plugins should not need this unless plugin author specifies it.
    
    # enable callback plugins, they can output to stdout but cannot be 'stdout' type.
    #callback_whitelist = timer, mail
    
    # Determine whether includes in tasks and handlers are "static" by
    # default. As of 2.0, includes are dynamic by default. Setting these
    # values to True will make includes behave more like they did in the
    # 1.x versions.
    #task_includes_static = False
    #handler_includes_static = False
    
    # Controls if a missing handler for a notification event is an error or a warning
    #error_on_missing_handler = True
    
    # change this for alternative sudo implementations
    #sudo_exe = sudo
    
    # What flags to pass to sudo
    # WARNING: leaving out the defaults might create unexpected behaviours
    #sudo_flags = -H -S -n
    
    # SSH timeout
    #timeout = 10
    
    # default user to use for playbooks if user is not specified
    # (/usr/bin/ansible will use current user as default)
    #remote_user = root
    
    # logging is off by default unless this path is defined
    # if so defined, consider logrotate
    #log_path = /var/log/ansible.log
    
    # default module name for /usr/bin/ansible
    #module_name = command
    
    # use this shell for commands executed under sudo
    # you may need to change this to bin/bash in rare instances
    # if sudo is constrained
    #executable = /bin/sh
    
    # if inventory variables overlap, does the higher precedence one win
    # or are hash values merged together?  The default is 'replace' but
    # this can also be set to 'merge'.
    #hash_behaviour = replace
    
    # by default, variables from roles will be visible in the global variable
    # scope. To prevent this, the following option can be enabled, and only
    # tasks and handlers within the role will see the variables there
    #private_role_vars = yes
    
    # list any Jinja2 extensions to enable here:
    #jinja2_extensions = jinja2.ext.do,jinja2.ext.i18n
    
    # if set, always use this private key file for authentication, same as
    # if passing --private-key to ansible or ansible-playbook
    #private_key_file = /path/to/file
    
    # If set, configures the path to the Vault password file as an alternative to
    # specifying --vault-password-file on the command line.
    #vault_password_file = /path/to/vault_password_file
    
    # format of string {{ ansible_managed }} available within Jinja2
    # templates indicates to users editing templates files will be replaced.
    # replacing {file}, {host} and {uid} and strftime codes with proper values.
    #ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}
    # {file}, {host}, {uid}, and the timestamp can all interfere with idempotence
    # in some situations so the default is a static string:
    #ansible_managed = Ansible managed
    
    # by default, ansible-playbook will display "Skipping [host]" if it determines a task
    # should not be run on a host.  Set this to "False" if you don't want to see these "Skipping"
    # messages. NOTE: the task header will still be shown regardless of whether or not the
    # task is skipped.
    #display_skipped_hosts = True
    
    # by default, if a task in a playbook does not include a name: field then
    # ansible-playbook will construct a header that includes the task's action but
    # not the task's args.  This is a security feature because ansible cannot know
    # if the *module* considers an argument to be no_log at the time that the
    # header is printed.  If your environment doesn't have a problem securing
    # stdout from ansible-playbook (or you have manually specified no_log in your
    # playbook on all of the tasks where you have secret information) then you can
    # safely set this to True to get more informative messages.
    #display_args_to_stdout = False
    
    # by default (as of 1.3), Ansible will raise errors when attempting to dereference
    # Jinja2 variables that are not set in templates or action lines. Uncomment this line
    # to revert the behavior to pre-1.3.
    #error_on_undefined_vars = False
    
    # by default (as of 1.6), Ansible may display warnings based on the configuration of the
    # system running ansible itself. This may include warnings about 3rd party packages or
    # other conditions that should be resolved if possible.
    # to disable these warnings, set the following value to False:
    #system_warnings = True
    
    # by default (as of 1.4), Ansible may display deprecation warnings for language
    # features that should no longer be used and will be removed in future versions.
    # to disable these warnings, set the following value to False:
    #deprecation_warnings = True
    
    # (as of 1.8), Ansible can optionally warn when usage of the shell and
    # command module appear to be simplified by using a default Ansible module
    # instead.  These warnings can be silenced by adjusting the following
    # setting or adding warn=yes or warn=no to the end of the command line
    # parameter string.  This will for example suggest using the git module
    # instead of shelling out to the git command.
    # command_warnings = False
    
    
    # set plugin path directories here, separate with colons
    #action_plugins     = /usr/share/ansible/plugins/action
    #cache_plugins      = /usr/share/ansible/plugins/cache
    #callback_plugins   = /usr/share/ansible/plugins/callback
    #connection_plugins = /usr/share/ansible/plugins/connection
    #lookup_plugins     = /usr/share/ansible/plugins/lookup
    #inventory_plugins  = /usr/share/ansible/plugins/inventory
    #vars_plugins       = /usr/share/ansible/plugins/vars
    #filter_plugins     = /usr/share/ansible/plugins/filter
    #test_plugins       = /usr/share/ansible/plugins/test
    #terminal_plugins   = /usr/share/ansible/plugins/terminal
    #strategy_plugins   = /usr/share/ansible/plugins/strategy
    
    
    # by default, ansible will use the 'linear' strategy but you may want to try
    # another one
    #strategy = free
    
    # by default callbacks are not loaded for /bin/ansible, enable this if you
    # want, for example, a notification or logging callback to also apply to
    # /bin/ansible runs
    #bin_ansible_callbacks = False
    
    
    # don't like cows?  that's unfortunate.
    # set to 1 if you don't want cowsay support or export ANSIBLE_NOCOWS=1
    #nocows = 1
    
    # set which cowsay stencil you'd like to use by default. When set to 'random',
    # a random stencil will be selected for each task. The selection will be filtered
    # against the `cow_whitelist` option below.
    #cow_selection = default
    #cow_selection = random
    
    # when using the 'random' option for cowsay, stencils will be restricted to this list.
    # it should be formatted as a comma-separated list with no spaces between names.
    # NOTE: line continuations here are for formatting purposes only, as the INI parser
    #       in python does not support them.
    #cow_whitelist=bud-frogs,bunny,cheese,daemon,default,dragon,elephant-in-snake,elephant,eyes,\
    #              hellokitty,kitty,luke-koala,meow,milk,moofasa,moose,ren,sheep,small,stegosaurus,\
    #              stimpy,supermilker,three-eyes,turkey,turtle,tux,udder,vader-koala,vader,www
    
    # don't like colors either?
    # set to 1 if you don't want colors, or export ANSIBLE_NOCOLOR=1
    #nocolor = 1
    
    # if set to a persistent type (not 'memory', for example 'redis') fact values
    # from previous runs in Ansible will be stored.  This may be useful when
    # wanting to use, for example, IP information from one group of servers
    # without having to talk to them in the same playbook run to get their
    # current IP information.
    #fact_caching = memory
    
    #This option tells Ansible where to cache facts. The value is plugin dependent.
    #For the jsonfile plugin, it should be a path to a local directory.
    #For the redis plugin, the value is a host:port:database triplet: fact_caching_connection = localhost:6379:0
    
    #fact_caching_connection=/tmp
    
    
    
    # retry files
    # When a playbook fails by default a .retry file will be created in ~/
    # You can disable this feature by setting retry_files_enabled to False
    # and you can change the location of the files by setting retry_files_save_path
    
    #retry_files_enabled = False
    #retry_files_save_path = ~/.ansible-retry
    
    # squash actions
    # Ansible can optimise actions that call modules with list parameters
    # when looping. Instead of calling the module once per with_ item, the
    # module is called once with all items at once. Currently this only works
    # under limited circumstances, and only with parameters named 'name'.
    #squash_actions = apk,apt,dnf,homebrew,pacman,pkgng,yum,zypper
    
    # prevents logging of task data, off by default
    #no_log = False
    
    # prevents logging of tasks, but only on the targets, data is still logged on the master/controller
    #no_target_syslog = False
    
    # controls whether Ansible will raise an error or warning if a task has no
    # choice but to create world readable temporary files to execute a module on
    # the remote machine.  This option is False by default for security.  Users may
    # turn this on to have behaviour more like Ansible prior to 2.1.x.  See
    # https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user
    # for more secure ways to fix this than enabling this option.
    #allow_world_readable_tmpfiles = False
    
    # controls the compression level of variables sent to
    # worker processes. At the default of 0, no compression
    # is used. This value must be an integer from 0 to 9.
    #var_compression_level = 9
    
    # controls what compression method is used for new-style ansible modules when
    # they are sent to the remote system.  The compression types depend on having
    # support compiled into both the controller's python and the client's python.
    # The names should match with the python Zipfile compression types:
    # * ZIP_STORED (no compression. available everywhere)
    # * ZIP_DEFLATED (uses zlib, the default)
    # These values may be set per host via the ansible_module_compression inventory
    # variable
    #module_compression = 'ZIP_DEFLATED'
    
    # This controls the cutoff point (in bytes) on --diff for files
    # set to 0 for unlimited (RAM may suffer!).
    #max_diff_size = 1048576
    
    # This controls how ansible handles multiple --tags and --skip-tags arguments
    # on the CLI.  If this is True then multiple arguments are merged together.  If
    # it is False, then the last specified argument is used and the others are ignored.
    # This option will be removed in 2.8.
    #merge_multiple_cli_flags = True
    
    # Controls showing custom stats at the end, off by default
    #show_custom_stats = True
    
    # Controls which files to ignore when using a directory as inventory with
    # possibly multiple sources (both static and dynamic)
    #inventory_ignore_extensions = ~, .orig, .bak, .ini, .cfg, .retry, .pyc, .pyo
    
    # This family of modules use an alternative execution path optimized for network appliances
    # only update this setting if you know how this works, otherwise it can break module execution
    #network_group_modules=eos, nxos, ios, iosxr, junos, vyos
    
    # When enabled, this option allows lookups (via variables like {{lookup('foo')}} or when used as
    # a loop with `with_foo`) to return data that is not marked "unsafe". This means the data may contain
    # jinja2 templating language which will be run through the templating engine.
    # ENABLING THIS COULD BE A SECURITY RISK
    #allow_unsafe_lookups = False
    
    # set default errors for all plays
    #any_errors_fatal = False
    
    [inventory]
    # enable inventory plugins, default: 'host_list', 'script', 'yaml', 'ini', 'auto'
    #enable_plugins = host_list, virtualbox, yaml, constructed
    
    # ignore these extensions when parsing a directory as inventory source
    #ignore_extensions = .pyc, .pyo, .swp, .bak, ~, .rpm, .md, .txt, ~, .orig, .ini, .cfg, .retry
    
    # ignore files matching these patterns when parsing a directory as inventory source
    #ignore_patterns=
    
    # If 'true' unparsed inventory sources become fatal errors, they are warnings otherwise.
    #unparsed_is_failed=False
    
    [privilege_escalation]
    #become=True
    #become_method=sudo
    #become_user=root
    #become_ask_pass=False
    
    [paramiko_connection]
    
    # uncomment this line to cause the paramiko connection plugin to not record new host
    # keys encountered.  Increases performance on new host additions.  Setting works independently of the
    # host key checking setting above.
    #record_host_keys=False
    
    # by default, Ansible requests a pseudo-terminal for commands executed under sudo. Uncomment this
    # line to disable this behaviour.
    #pty=False
    
    # paramiko will default to looking for SSH keys initially when trying to
    # authenticate to remote devices.  This is a problem for some network devices
    # that close the connection after a key failure.  Uncomment this line to
    # disable the Paramiko look for keys function
    #look_for_keys = False
    
    # When using persistent connections with Paramiko, the connection runs in a
    # background process.  If the host doesn't already have a valid SSH key, by
    # default Ansible will prompt to add the host key.  This will cause connections
    # running in background processes to fail.  Uncomment this line to have
    # Paramiko automatically add host keys.
    #host_key_auto_add = True
    
    [ssh_connection]
    
    # ssh arguments to use
    # Leaving off ControlPersist will result in poor performance, so use
    # paramiko on older platforms rather than removing it, -C controls compression use
    #ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s
    
    # The base directory for the ControlPath sockets.
    # This is the "%(directory)s" in the control_path option
    #
    # Example:
    # control_path_dir = /tmp/.ansible/cp
    #control_path_dir = ~/.ansible/cp
    
    # The path to use for the ControlPath sockets. This defaults to a hashed string of the hostname,
    # port and username (empty string in the config). The hash mitigates a common problem users
    # found with long hostames and the conventional %(directory)s/ansible-ssh-%%h-%%p-%%r format.
    # In those cases, a "too long for Unix domain socket" ssh error would occur.
    #
    # Example:
    # control_path = %(directory)s/%%h-%%r
    #control_path =
    
    # Enabling pipelining reduces the number of SSH operations required to
    # execute a module on the remote server. This can result in a significant
    # performance improvement when enabled, however when using "sudo:" you must
    # first disable 'requiretty' in /etc/sudoers
    #
    # By default, this option is disabled to preserve compatibility with
    # sudoers configurations that have requiretty (the default on many distros).
    #
    #pipelining = False
    
    # Control the mechanism for transferring files (old)
    #   * smart = try sftp and then try scp [default]
    #   * True = use scp only
    #   * False = use sftp only
    #scp_if_ssh = smart
    
    # Control the mechanism for transferring files (new)
    # If set, this will override the scp_if_ssh option
    #   * sftp  = use sftp to transfer files
    #   * scp   = use scp to transfer files
    #   * piped = use 'dd' over SSH to transfer files
    #   * smart = try sftp, scp, and piped, in that order [default]
    #transfer_method = smart
    
    # if False, sftp will not use batch mode to transfer files. This may cause some
    # types of file transfer failures impossible to catch however, and should
    # only be disabled if your sftp version has problems with batch mode
    #sftp_batch_mode = False
    
    # The -tt argument is passed to ssh when pipelining is not enabled because sudo 
    # requires a tty by default. 
    #use_tty = True
    
    # Number of times to retry an SSH connection to a host, in case of UNREACHABLE.
    # For each retry attempt, there is an exponential backoff,
    # so after the first attempt there is 1s wait, then 2s, 4s etc. up to 30s (max).
    #retries = 3
    
    [persistent_connection]
    
    # Configures the persistent connection timeout value in seconds.  This value is
    # how long the persistent connection will remain idle before it is destroyed.
    # If the connection doesn't receive a request before the timeout value
    # expires, the connection is shutdown. The default value is 30 seconds.
    #connect_timeout = 30
    
    # Configures the persistent connection retry timeout.  This value configures the
    # the retry timeout that ansible-connection will wait to connect
    # to the local domain socket. This value must be larger than the
    # ssh timeout (timeout) and less than persistent connection idle timeout (connect_timeout).
    # The default value is 15 seconds.
    #connect_retry_timeout = 15
    
    # The command timeout value defines the amount of time to wait for a command
    # or RPC call before timing out. The value for the command timeout must
    # be less than the value of the persistent connection idle timeout (connect_timeout)
    # The default value is 10 second.
    #command_timeout = 10
    
    [accelerate]
    #accelerate_port = 5099
    #accelerate_timeout = 30
    #accelerate_connect_timeout = 5.0
    
    # The daemon timeout is measured in minutes. This time is measured
    # from the last activity to the accelerate daemon.
    #accelerate_daemon_timeout = 30
    
    # If set to yes, accelerate_multi_key will allow multiple
    # private keys to be uploaded to it, though each user must
    # have access to the system via SSH to add a new key. The default
    # is "no".
    #accelerate_multi_key = yes
    
    [selinux]
    # file systems that require special treatment when dealing with security context
    # the default behaviour that copies the existing context or uses the user default
    # needs to be changed to use the file system dependent context.
    #special_context_filesystems=nfs,vboxsf,fuse,ramfs,9p
    
    # Set this to yes to allow libvirt_lxc connections to work without SELinux.
    #libvirt_lxc_noseclabel = yes
    
    [colors]
    #highlight = white
    #verbose = blue
    #warn = bright purple
    #error = red
    #debug = dark gray
    #deprecate = purple
    #skip = cyan
    #unreachable = red
    #ok = green
    #changed = yellow
    #diff_add = green
    #diff_remove = red
    #diff_lines = cyan
    
    
    [diff]
    # Always print diff when running ( same as always running with -D/--diff )
    # always = no
    
    # Set how many context lines to show in diff
    # context = 3
    

     

     

    =========================

    ssh 登录出现Are you sure you want to continue connecting (yes/no)?解决方法

    1. 可以使用ssh -o 的参数进行设置
    例如: ssh -o StrictHostKeyChecking=no root@192.168.111.22
    2. 修改/etc/ssh/ssh_config
    将其中的

    # StrictHostKeyChecking ask

    改成

    StrictHostKeyChecking no

    展开全文
  • 片段中的适配器 - android.app.Application无法强制转换为android.app.Activity(adapter in fragment - android.app.Application cannot be cast to android.app.Activity)所以现在我们有了CustomAdapter adapter = ...

    片段中的适配器 - android.app.Application无法强制转换为android.app.Activity(adapter in fragment - android.app.Application cannot be cast to android.app.Activity)

    所以现在我们有了

    CustomAdapter adapter = new CustomAdapter(getActivity().getApplicationContext(), R.layout.list_style, RowBean_data);

    ListView lista = (ListView) rootView.findViewById(R.id.lista);

    lista.setAdapter(adapter);

    在片段中,我们希望它显示包含项目和文本的列表。

    其他课程:

    我们怎样才能让它发挥作用?

    so now we've got a

    CustomAdapter adapter = new CustomAdapter(getActivity().getApplicationContext(), R.layout.list_style, RowBean_data);

    ListView lista = (ListView) rootView.findViewById(R.id.lista);

    lista.setAdapter(adapter);

    in fragment, we want it to show a list with items and text.

    Right now we're getting an error with the following code: http://pastebin.com/BV9X6Dys

    The other classes:

    How can we make it work?

    原文:https://stackoverflow.com/questions/32523767

    更新时间:2019-10-30 20:01

    最满意答案

    您正在将Context为Activity 。

    错误在这里..

    LayoutInflater inflater = ((Activity)context).getLayoutInflater();

    因此,解决方案是使用context来获取充气机服务,就像这样

    LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    另一种替代方式就是这样

    LayoutInflater inflater = LayoutInflater.from(context);

    就像@Zharf说的那样

    编辑

    另外我认为将getActivity()传递给CustomAdapter的构造函数就足够了。

    CustomAdapter adapter = new CustomAdapter(getActivity(), R.layout.list_style, RowBean_data);

    You are casting Context to Activity.

    The error is here..

    LayoutInflater inflater = ((Activity)context).getLayoutInflater();

    So the solution is to use the context to get the inflator service, like this

    LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    Another alternate way is that like this

    LayoutInflater inflater = LayoutInflater.from(context);

    Like @Zharf said

    EDIT

    Also I think that passing getActivity() to the CustomAdapter's constructor is enough.

    CustomAdapter adapter = new CustomAdapter(getActivity(), R.layout.list_style, RowBean_data);

    2015-09-11

    相关问答

    您正在将Context为Activity 。 错误在这里.. LayoutInflater inflater = ((Activity)context).getLayoutInflater();

    因此,解决方案是使用context来获取充气机服务,就像这样 LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    另一种替代方式就是这样 Layout

    ...

    您的“主”类不会扩展活动。 我只能看到你的清单和StackTrace。 Your "Main" class doesn't extend Activity. That's all I can see with only your manifest and StackTrace.

    这里最小清单定义包,应用程序上下文和主要活动: <?xml version="1.0" encoding="utf-8"?>

    package="my.app.package.name">

    android:name=".MyCustomApplicationContext"

    android

    ...

    该错误指出getApplication返回的对象的类型是android.app.Application 。 可能的原因是您无法在清单中定义应用程序。 确保您的清单包含以下内容:

    The error states that the type of the object returned by getApplication is android.app.Application. A possib

    ...

    你正在咆哮错误的树;-)你的Service不应该知道你的用户界面,也不应该想知道它。 如果要从Service更改UI,则需要将该任务委派给Activity 。 Activity负责UI。 您可以使用几种记录良好的方法: Activity绑定到Service和Service在Activity上执行回调 Service发送广播Intent和Activity注册一个侦听器,该侦听器在广播时对Intent作出反应 使用Event Bus实现 You are barking up the wrong tre

    ...

    你所做的不是使用activity的正确方法。如果你想要这个类应该在后台运行然后将它声明为Service .Activity有自己的生命周期,你必须遵循 。 What you did is not the correct way of using activity.If you want this class should be run in the background then declare it as Service.Activity is having its own life-cycle

    ...

    我发现了一个更简单的方法 - 我传递了View变量并用Activity初始化代替它。 片段: BackgroundTaskJobs backgroundTaskJobs= new BackgroundTaskJobs(getActivity()); backgroundTaskJobs.execute(); BackgroundTaskJobs backgroundTaskJobs= new BackgroundTaskJobs(getActivity()); backgroundTaskJobs

    ...

    如果您遵循Android命名约定,则错误非常有意义。 public class MainActivity extends Fragment {

    片段不是活动,也不能这样生成。 改回来。 public class MainActivity extends AppCompatActivity {

    并学习如何正确创建片段 。 If you followed Android naming conventions, then the error makes perfect sense. public

    ...

    即使您在活动中,上下文也不总是活动。 它可以是一个应用程序,也可以是另一个上下文的包装器。 将Context转换为Activity几乎总是错误的。 如果你绝对需要一个,你应该传入一个Activity作为参数,而不是一个Context。 或者更好的是,直接传递支持片段管理器而不是活动,因为这就是你需要的全部内容。 A context is not always an Activity, even when you're in an Activity. It could be an Applicati

    ...

    Activity扩展了ContextThemeWrapper因此导致了转换异常,因为ContextThemeWrapper不是Activity的实例。 它本身可能是另一个子类或ContextThemeWrapper 。 要在片段中获取Activity上下文,可以使用getActivity()而不是getView().getContext() Activity extends ContextThemeWrapper so the cast exception is caused because yo

    ...

    展开全文
  • doing与to do的用法

    2020-12-19 23:37:34
    ( 未 做但要做 ) You must try to be more careful .你可要多加小心。 Let ’ s try doing the work some other way .让我们试一试用另外一种办法来做这工作。 I didn ’ t mean to hurt your...

    1.finish,

    enjoy,

    feel

    like,

    consider,imagine,

    keep,postpone,

    dely,mind,practise,

    suggest,risk,quit+doing

    2.1

    )

    forget to do

    忘记要去做某事(此事未做)

    forget doing

    忘记做过某事(此事已做过或已发生)

    2

    )

    stop to do

    停止、中断(某件事)

    ,目的是去做另一件事

    stop doing

    停止正在或经常做的事

    3

    )

    remember to do

    记住去做某事(未做)

    remember doing

    记得做过某事

    (

    已做

    )

    4) regret to do

    对要做的事遗憾

    regret doing

    对做过的事遗憾、后悔

    5

    )

    try to do

    努力、企图做某事

    try doing

    试验、试一试某种办法

    6) mean to do

    打算,有意要„

    mean doing

    意味着

    7

    )

    go on to do

    继而(去做另外一件事情)

    go on doing

    继续(原先没有做完的事情)

    8

    )

    propose to do

    打算(要做某事)

    proposing doing

    建议(做某事)

    9) like /love/hate/ prefer +to do

    表示具体行为;

    +doing sth

    表示抽象、倾向概念

    (注

    )

    如果这些动词前有

    should

    一词,其后宾语只跟不定式,不能跟动名词。例如:

    I should like to see him tomorrow

    10) need, want, deserve +

    动名词表被动意义;

    +

    不定式被动态表示“要

    (

    修、清理等

    )

    ”意思。

    Don

    t you remember seeing the man before?

    你不记得以前见过那个人吗

    ?

    You must remember to leave tomorrow

    .你可要记着是明天动身。

    I don

    t regret telling her what I thought

    .我不后悔给她讲过我的想法。

    (

    已讲过

    )

    I regret to have to do this

    but I have no choice

    我很遗憾必须这样去做,

    我实在没办法。

    (

    做但要做

    )

    You must try to be more careful

    .你可要多加小心。

    Let

    s try doing the work some other way

    .让我们试一试用另外一种办法来做这工作。

    I didn

    t mean to hurt your feeling

    .我没想要伤害你的感情。

    This illness will mean (your) going to hospital

    .得了这种病

    (

    )

    就要进医院。

    3.

    to

    的动词不定式

    1

    )

    情态动词

    (

    ought

    外,

    ought to)

    2

    )

    使役动词

    let, have, make

    3

    )

    感官动词

    see, watch, look at, notice , observe, hear, listen to, smell, feel, find

    等后作宾补,

    省略

    to

    注意:在被动语态中则

    to

    不能省掉。

    I saw him dance.

    =He was seen to dance.

    The boss made them work the whole night.

    =They were made to work the whole night.

    4

    )

    would rather

    had better

    展开全文
  • 动词不定式短语的主干是由 to + 动词原形构成,动词不定式短语内部的动词可以跟自己的宾语、状语、表语等成分。动词不定式短语整体上在句中起名词,形容词和副词的作用,可以担任除谓语以外的其它任何成分。 2 动词...

    1 动词不定式短语的结构

    动词不定式短语的主干是由 to + 动词原形构成,动词不定式短语内部的动词可以跟自己的宾语、状语、表语等成分。动词不定式短语整体上在句中起名词,形容词和副词的作用,可以担任除谓语以外的其它任何成分。

    2 动词不定式短语在句子中的作用

    2.1 动词不定式短语做主语:

    • To master a language is not an easy thing。
      掌握一门语言不是一件容易的事情。
    • It’s my pleasure to help you。
      帮助你是我的乐趣。
      动词不定式做主语时可以放在后面,而用 it 作形式主语放在原主语的位置上。

    2.2 动词不定式短语作宾语:

    • I like to help others as much as possible。
      如果有可能的话,我喜欢帮助别人。

    2.3 动词不定式短语作宾语补语:

    表示不定式的动作是由宾语发出。

    • We expect you to be with us.
      我们希望你和我们在一起。

    2.3.1 动词+宾语+不带to的不定式作宾语补足语:

    感官动词:see, watch, notice, look at,hear;使役动词:make, let, have(使得),help(可带to, 也可不带to)

    • The teacher has his students write a composition every other week。
      老师让同学们每隔一周写一篇作文。
    • Many things【make people think artists are weird】。
      很多事情使人们觉得艺术家们很奇怪。

    2.4 动词不定式短语作表语:

    • The most urgent thing is to take legal measures immediately。
      当务之急是马上采取法律措施。

    2.5 动词不定式短语作定语:

    • There are many ways to solve the problem.
      有许多方法能解决这个问题。

    2.6 动词不定式短语作状语:经常表示目的。

    • We went to the hospital to see our teacher.
      我们去医院看了我们的老师。
    • She is making a test to get a kind of useful medicine from a Tibet flower。
      她在做试验,以从一种西藏花中提取某种有用的药物。

    3 动词不定式主干的否定形式:

    3.1 not + to + 动词原形

    • The teacher told us not to swim in that river。
      老师告诉我们不要在那条河里游泳。
    • It’s unfair not to tell us.
      没告诉我们真是不公平。

    3.2 带疑问词的动词不定式短语:

    疑问词who, what, which, when, where, how, why 以及whether可以加在动词不定式短语的前面,构成不定式短语,使含义更加具体。整体上相当于一个名词短语。

    • Where to go is not known yet。
      去什么地方还不知道。
    • I don’t know when to begin.
      我不知道什么时间开始。

    3.3 带逻辑主语的动词不定式短语:

    为了特别说明动词不定式短语动作的发出者,动词不定式可以带有自己的逻辑主语,构成方法是: for + 逻辑主语 + 不定式。

    注意:逻辑主语用宾格形式, for 本身无实际意义,它只表明后面的主语从逻辑上分析是不定式的主语。

    • It’s necessary for us to help each other。
      我们互相帮忙是必要的。
    • There is much work for me to finish,
      有许多工作要我去完成。

    4 动词不定式短语的时态:

    4.1 动词不定式短语一般时态:

    表示动作和句中谓语动词的动作同时发生或在之后发生。

    • I helped him to put the things into the car.
      我帮助他把东西放进了汽车。
    • I want to see you again.
      我想再见到你。

    4.2 动词不定式短语的完成时:

    表示动作在句中谓语动词的动作之前发生。

    展开全文
  • 区别的to do和doing用法的小技巧

    千次阅读 2020-12-19 08:30:56
    want to do sth. 想要做某事I want to buy a new computer this afternoon.我想今天下午买台新电脑。2. would like to do sth.想要做某事I would like to invite you to come to my birthday party this Saturday....
  • 我想显示一条消息,显示我选择的内容(Java)(I want to display a message showing what I selected (Java))我正在做一个项目(像餐馆)来拼贴,而我在Java中并不擅长(他们并没有真的试图教我们)。 该项目的原则是显示...
  • I want you to know we all are here to help you, but you need to deep dive into the problem. If every time we’ll help you, then it is spoonfeeding which won’t help you in the long run.” That day I ...
  • 在用pandas的时候,写了这一段语句 `nd = d.reindex(index = ni,columns = nc,method = 'bfill')`,报错index must be monotonic increasing or decreasing,没找到比较好的解释,就自己推了一下
  • onclick必须点击两次才能触发(onclick has to be clicked twice to fire)除非点击两次,否则我的onclick函数将不会触发。 我对javascript很新,但到目前为止,我在var obj行中移动,并将==“none”更改为“none”?...
  • 其实每节英语课上老师都会提到一些to do, doing, do,你也许也在笔记上认真的记了,可是由于没有及时复习加之这些用法分散在笔记本、课本和练习册等各个地方,并不能系统的记忆。今天小七老师就帮大家总结一下初中...
  • wish to do造句

    2021-01-17 11:14:35
    有wish to do sth。吗???有(看例句1)wish表示“希望”(大多难以实现或与事实相反),往往带有“祝愿”的意味。wish后常跟不定式、双宾语、复合宾语(宾语+形容词/副词)、for+名词、宾语+不定式等结构。例如:(例句1)I ...
  • commsrc.pn(To be removed) Create PN sequence generatorobjectCompatibilitycommsrc.pn will be removed in a future release. To generate a pseudo-noise (PN)sequence, use the comm.PNSequence System object ...
  • 比喻意义:坚持做62616964757a686964616fe59b9ee7ad9431333363396365什么或者使用什么,尤其是在一个困难的情况下。E.g.You should stick to it and never give up.你应该坚持下去,永不放弃。be s...
  • 今天帮小飞为你总结了初中阶段高频出现的一些动词用法,让你从此告别看到to do, doing, do就一脸懵的囧状。一. 加to do的高频考查动词1. afford to do 负担的起做某事We can’t afford to make an...
  • SELECTyourTable.ID,regexp_split_to_table(yourTable.fruits, E'|') AS split_fruitsFROM yourTableI get the following:ERROR: type "e" does not existQ1. What does the E do? I saw some examples where E is n...
  • 数组到字符串转换(Array to string conversion)这段代码有什么问题? 我不明白。 这是错误代码:注意:第12行的C:\ xampp \ htdocs \ stage \ ripper.php中的数组到字符串转换数组块引用注意:第13行数组中C:\ ...
  • call的用法及短语例句

    2020-12-22 00:23:42
    call的用法call可用作不及物动词,也可用作及物动词。作“喊”“叫”解时,多接简单宾语; 作“叫来”“请来”解时,多接双宾语,其间接宾语可转化为介词to的宾语;作“命名”“称为”“认为是”解时,可接以名词或形容...
  • Unit 6 - How to Mark a Book "Don't ever mark in a book!" Thousands of teachers, librarians and parents have so advised. But Mortimer Adler disagrees. He thinks so long as you own the book and needn't...
  • MATLAB 报错 The S-Function sourse file cannot be foundS-Function函数报错解决办法 ...It could be either that the file does not exist,or it’s not on your MATLAB path.Do you want to manually
  • 使用方法

    2021-08-04 05:32:59
    Compile .less files to .css using the command lineHeads up! If the command line isn't your thing, learn more about GUIs for Less.Installing lessc for Use GloballyInstall with npmnpm install less -gand...
  • 全部四级六级高考考研Either way, we have choices about how we respond to it when it comes.出自-2017年6月阅读原文SimpliSafe, winner of our Editor's Choice distinction, utilizes a special system that's ...
  • (I want to find column name in my database - is it possible?)我的数据库名称是CARE_DynamicsAX ,我想找到一个列名workerStatusMy database name is CARE_DynamicsAX and I want to find a column name work...
  • Stick to和Stick with的区别

    千次阅读 2020-12-19 00:27:31
    比喻意义:坚持做62616964757a686964616fe59b9ee7ad9431333363396365什么或者使用什么,尤其是在一个困难的情况下。E.g.You should stick to it and never give up.你应该坚持下去,永不放弃。be s...
  • springboot2启动项目报错,应该是数据库连接的问题,导致无法启动。 错误消息如下: ...Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be con
  • Unit 5A -For Want of a Drink For Want of a Drink Author Unknown ... Water, it is said, is the new oil: a resource long squandered, now growing expensive and soon to be overwhelmed .
  • SpringBoot 启动失败 ...Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured. Reason: Failed to determine a suitable dr
  • would用法归纳(最全)

    千次阅读 2021-04-07 15:48:18
    a)she would be there the next day b)i would face to her parents 2、would you 表示一种委婉,客气说法 a)would you like to have a cup of tea? b)would you mind my smoking here? c)would you tell me the ...
  • Converts Quill's delta ops to HTML Quill Delta to HTML ConverterConverts Quill's Delta format to HTML (insert ops only) with properly nested lists.You can try a live demo of the conversion by opening ...
  • How can I redirect the user from one page to another using jQuery or pure JavaScript? 如何使用jQuery或纯JavaScript将用户从一个页面重定向到另一个页面? 67 个解决方案 #1 12438 One does not simply ...
  • Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class Action: Consider the ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 130,275
精华内容 52,110
关键字:

be用法towant