• <legend id='7FKnT'><style id='7FKnT'><dir id='7FKnT'><q id='7FKnT'></q></dir></style></legend>

        <tfoot id='7FKnT'></tfoot>
        <i id='7FKnT'><tr id='7FKnT'><dt id='7FKnT'><q id='7FKnT'><span id='7FKnT'><b id='7FKnT'><form id='7FKnT'><ins id='7FKnT'></ins><ul id='7FKnT'></ul><sub id='7FKnT'></sub></form><legend id='7FKnT'></legend><bdo id='7FKnT'><pre id='7FKnT'><center id='7FKnT'></center></pre></bdo></b><th id='7FKnT'></th></span></q></dt></tr></i><div id='7FKnT'><tfoot id='7FKnT'></tfoot><dl id='7FKnT'><fieldset id='7FKnT'></fieldset></dl></div>
      1. <small id='7FKnT'></small><noframes id='7FKnT'>

          <bdo id='7FKnT'></bdo><ul id='7FKnT'></ul>
      2. Toast 类型中的方法 makeText 不适用于参数

        时间:2023-10-04
        • <bdo id='7KsfW'></bdo><ul id='7KsfW'></ul>

                <tbody id='7KsfW'></tbody>

            • <i id='7KsfW'><tr id='7KsfW'><dt id='7KsfW'><q id='7KsfW'><span id='7KsfW'><b id='7KsfW'><form id='7KsfW'><ins id='7KsfW'></ins><ul id='7KsfW'></ul><sub id='7KsfW'></sub></form><legend id='7KsfW'></legend><bdo id='7KsfW'><pre id='7KsfW'><center id='7KsfW'></center></pre></bdo></b><th id='7KsfW'></th></span></q></dt></tr></i><div id='7KsfW'><tfoot id='7KsfW'></tfoot><dl id='7KsfW'><fieldset id='7KsfW'></fieldset></dl></div>

              1. <small id='7KsfW'></small><noframes id='7KsfW'>

                  <tfoot id='7KsfW'></tfoot><legend id='7KsfW'><style id='7KsfW'><dir id='7KsfW'><q id='7KsfW'></q></dir></style></legend>
                • 本文介绍了Toast 类型中的方法 makeText 不适用于参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当我们滚动到下一个片段页面时,我正在使用 ViewPageIndicator 并尝试使用 Toast 来显示.

                  I am using a ViewPageIndicator and trying to use a Toast to display when we scroll to the next fragment page.

                  我让他跟随错误

                  The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (PlaceDetailsFragment, String, int)
                  

                  PlaceDetailsFragment.java

                  public class PlaceDetailsFragment extends SherlockFragment {
                      ImageFragmentAdapter mAdapter;
                      ViewPager mPager;
                      PageIndicator mIndicator;
                  
                      @Override
                      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
                          View view = inflater.inflate(R.layout.fragment_place_details, container,
                                  false);
                  
                          mAdapter = new ImageFragmentAdapter(getActivity()
                                  .getSupportFragmentManager());
                  
                          mPager = (ViewPager) view.findViewById(R.id.pager);
                          mPager.setAdapter(mAdapter);
                  
                          mIndicator = (CirclePageIndicator) view.findViewById(R.id.indicator);
                          mIndicator.setViewPager(mPager);
                          ((CirclePageIndicator) mIndicator).setSnap(true);
                  
                          mIndicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
                              @Override
                              public void onPageSelected(int position) {
                                  Toast.makeText(PlaceDetailsFragment.this, "Changed to page " + position, Toast.LENGTH_SHORT).show();
                              }
                  
                              @Override
                              public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                              }
                  
                              @Override
                              public void onPageScrollStateChanged(int state) {
                              }
                          });
                          return view;
                      }
                  
                  }
                  

                  推荐答案

                  片段不扩展上下文.您必须让活动作为上下文传递.

                  Fragments don't extend context. You have to get the activity to pass as the context.

                  Toast.makeText(PlaceDetailsFragment.this.getActivity(), "Changed to page " + position, Toast.LENGTH_SHORT).show();
                  

                  这篇关于Toast 类型中的方法 makeText 不适用于参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:由于导航回旧片段,查看 Pager Crash Null Pointer Exception - Android 下一篇:如何在我的 Activity 中重新启动 Fragment - Android

                  相关文章

                  <tfoot id='u6JNe'></tfoot>

                      <bdo id='u6JNe'></bdo><ul id='u6JNe'></ul>
                    <legend id='u6JNe'><style id='u6JNe'><dir id='u6JNe'><q id='u6JNe'></q></dir></style></legend>

                    <small id='u6JNe'></small><noframes id='u6JNe'>

                    <i id='u6JNe'><tr id='u6JNe'><dt id='u6JNe'><q id='u6JNe'><span id='u6JNe'><b id='u6JNe'><form id='u6JNe'><ins id='u6JNe'></ins><ul id='u6JNe'></ul><sub id='u6JNe'></sub></form><legend id='u6JNe'></legend><bdo id='u6JNe'><pre id='u6JNe'><center id='u6JNe'></center></pre></bdo></b><th id='u6JNe'></th></span></q></dt></tr></i><div id='u6JNe'><tfoot id='u6JNe'></tfoot><dl id='u6JNe'><fieldset id='u6JNe'></fieldset></dl></div>