1. <small id='OzG9K'></small><noframes id='OzG9K'>

      <legend id='OzG9K'><style id='OzG9K'><dir id='OzG9K'><q id='OzG9K'></q></dir></style></legend>

        <tfoot id='OzG9K'></tfoot>

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

        带有页面指示器的 Android 视图寻呼机

        时间:2023-10-04

          <tbody id='jFpPG'></tbody>
        <tfoot id='jFpPG'></tfoot>
          <bdo id='jFpPG'></bdo><ul id='jFpPG'></ul>

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

              1. <legend id='jFpPG'><style id='jFpPG'><dir id='jFpPG'><q id='jFpPG'></q></dir></style></legend>
              2. <i id='jFpPG'><tr id='jFpPG'><dt id='jFpPG'><q id='jFpPG'><span id='jFpPG'><b id='jFpPG'><form id='jFpPG'><ins id='jFpPG'></ins><ul id='jFpPG'></ul><sub id='jFpPG'></sub></form><legend id='jFpPG'></legend><bdo id='jFpPG'><pre id='jFpPG'><center id='jFpPG'></center></pre></bdo></b><th id='jFpPG'></th></span></q></dt></tr></i><div id='jFpPG'><tfoot id='jFpPG'></tfoot><dl id='jFpPG'><fieldset id='jFpPG'></fieldset></dl></div>

                  本文介绍了带有页面指示器的 Android 视图寻呼机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要在带有图像的视图寻呼机文件中获取页面指示器.这是我的代码.

                  I need to get page indicator in the view pager file with images. Here is my code.

                  public class IndicatorActivity extends Activity {
                  
                  
                   /** Called when the activity is first created. */
                      @Override
                  
                          public void onCreate(Bundle savedInstanceState) {
                              super.onCreate(savedInstanceState);
                              setContentView(R.layout.main);
                  
                              MyPagerAdapter adapter = new MyPagerAdapter();
                              ViewPager myPager = (ViewPager) findViewById(R.id.pager);
                              myPager.setAdapter(adapter);
                              myPager.setCurrentItem(0);
                              TitlePageIndicator indicator = (TitlePageIndicator)findViewById(R.id.indicat);
                              indicator.setViewPager( myPager );
                      }
                  }
                  

                  在此代码中,我在 TitlePageIndicator indicator = (TitlePageIndicator)findViewById(R.id.indicat); 中遇到错误,因为 TitlePageIndicator 无法解析为类型.这是什么错误.我该如何解决?

                  In this code, i got an error in TitlePageIndicator indicator = (TitlePageIndicator)findViewById(R.id.indicat); as TitlePageIndicator cannot be resolved to a type. What is this error. How can I resolve it?

                  这是我的 xml 代码:

                  here is my xml code:

                  <?xml version="1.0" encoding="utf-8"?>
                  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                      android:layout_width="fill_parent"
                      android:layout_height="fill_parent"
                      android:orientation="vertical" >
                  
                      <android.support.v4.view.ViewPager
                          android:id="@+id/pager"
                          android:layout_width="match_parent"
                          android:layout_height="match_parent"
                           />
                      <com.viewpagerindicator.TitlePageIndicator
                      android:id="@+id/indicat"
                      android:layout_height="wrap_content"
                      android:layout_width="fill_parent" />
                  </LinearLayout>
                  

                  TitlePageIndicator需要写什么代码?我想在不使用片段的情况下做到这一点.

                  我还创建了一个类如:

                  class MyPagerAdapter extends PagerAdapter {
                  
                       private static Integer[] titles = new Integer[] 
                                  { 
                          R.drawable.jk,R.drawable.lm,R.drawable.no
                                  };
                  
                      public int getCount() {
                              return 3;
                      }
                  
                      public Object instantiateItem(View collection, int position) {
                  
                              LayoutInflater inflater = (LayoutInflater) collection.getContext()
                                              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                              View view;
                              ImageView iv;
                  
                              view = inflater.inflate(R.layout.first, null);
                  
                              ((ViewPager) collection).addView(view, 0);
                              switch (position) {
                              case 0:
                                  iv = (ImageView)view.findViewById(R.id.imageView1);
                                  iv.setImageResource(titles[position]);
                                      break;
                              case 1:
                                  iv = (ImageView)view.findViewById(R.id.imageView1);
                                  iv.setImageResource(titles[position]);
                                      break;
                              case 2:
                                   iv = (ImageView)view.findViewById(R.id.imageView1);
                                  iv.setImageResource(titles[position]);
                                      break;
                              }
                              return view;
                      }
                  
                      public void destroyItem(View arg0, int arg1, Object arg2) {
                              ((ViewPager) arg0).removeView((View) arg2);
                  
                      }
                  
                  
                  
                      public boolean isViewFromObject(View arg0, Object arg1) {
                              return arg0 == ((View) arg1);
                  
                      }
                  
                  }
                  

                  除了这门课,我还想做点什么吗?

                  Did I want to do anything more than this class?

                  提前感谢您的帮助

                  推荐答案

                  你需要做以下几件事:

                  1-如果您还没有这样做,请下载 库.

                  1-Download the library if you haven't already done that.

                  2- 导入 Eclipse.

                  2- Import into Eclipse.

                  3- 设置您的项目以使用该库:Project-> Properties -> Android -> 向下滚动到 Library 部分,单击 Add... 并选择 viewpagerindicator.

                  3- Set you project to use the library: Project-> Properties -> Android -> Scroll down to Library section, click Add... and select viewpagerindicator.

                  4- 现在您应该可以导入 com.viewpagerindicator.TitlePageIndicator.

                  4- Now you should be able to import com.viewpagerindicator.TitlePageIndicator.

                  现在关于在不使用片段的情况下实现这一点:

                  Now about implementing this without using fragments:

                  viewpagerindicatior 附带的示例中,您可以看到该库正在与具有 FragmentPagerAdapterViewPager 一起使用.

                  In the sample that comes with viewpagerindicatior, you can see that the library is being used with a ViewPager which has a FragmentPagerAdapter.

                  但实际上库本身是 Fragment 独立的.它只需要一个ViewPager.所以只需使用 PagerAdapter 而不是 FragmentPagerAdapter 就可以了.

                  But in fact the library itself is Fragment independant. It just needs a ViewPager. So just use a PagerAdapter instead of a FragmentPagerAdapter and you're good to go.

                  这篇关于带有页面指示器的 Android 视图寻呼机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:片段共享元素转换不适用于 ViewPager 下一篇:Android 2.2 + ViewPager和Fragments实现TabHost使用教程

                  相关文章

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

                    <legend id='6jqpP'><style id='6jqpP'><dir id='6jqpP'><q id='6jqpP'></q></dir></style></legend>