<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                activity_main.xml: ~~~ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity" > <Gallery android:id="@+id/gallery" android:layout_width="match_parent" android:layout_height="wrap_content" /> <ImageSwitcher android:id="@+id/imageSwitcher" android:layout_marginTop="150dp" android:layout_width="match_parent" android:layout_height="wrap_content" > </ImageSwitcher> </LinearLayout> ~~~ 自定義的ImageAdapter: ~~~ public class ImageAdapter extends BaseAdapter { private int[] res; private Context context; public ImageAdapter(int[] res,Context context) { super(); this.res = res; this.context=context; } @Override public int getCount() { // TODO Auto-generated method stub return Integer.MAX_VALUE; //以便“無限”循環顯示(一般情況下滾動不到這個最大值) } @Override public Object getItem(int position) { // TODO Auto-generated method stub return res[position]; } @Override public long getItemId(int position) { // TODO Auto-generated method stub return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub ImageView imageView=new ImageView(context); imageView.setBackgroundResource(res[position%res.length]); //無限“循環”顯示 imageView.setLayoutParams(new Gallery.LayoutParams(200, 150)); // imageView.setScaleType(ScaleType.FIT_XY); //設置拉伸效果 return imageView; } } ~~~ MainActivity.java ~~~ public class MainActivity extends Activity implements OnItemSelectedListener,ViewFactory{ //準備數據源 private int[] resIcon = { R.drawable.item1, R.drawable.item2, R.drawable.item3, R.drawable.item4, R.drawable.item5, R.drawable.item6, R.drawable.item7, R.drawable.item8, R.drawable.item9, R.drawable.item10, R.drawable.item11, R.drawable.item12 }; private Gallery gallery; private ImageAdapter adapter; private ImageSwitcher imageSwitcher; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); gallery=(Gallery) findViewById(R.id.gallery); imageSwitcher=(ImageSwitcher) findViewById(R.id.imageSwitcher); //gallery加載適配器 adapter=new ImageAdapter(resIcon, this); gallery.setAdapter(adapter); //設置監聽器 gallery.setOnItemSelectedListener(this); //ImageSwitcher imageSwitcher.setFactory(this); imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in)); imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out)); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // imageView.setBackgroundResource(res[position%res.length]); //無限“循環”顯示 imageSwitcher.setBackgroundResource(resIcon[position%resIcon.length]); } @Override public View makeView() { // TODO Auto-generated method stub ImageView imageView=new ImageView(this); imageView.setScaleType(ScaleType.FIT_CENTER); return imageView; } @Override public void onNothingSelected(AdapterView<?> parent) { // TODO Auto-generated method stub } } ~~~ 效果圖: ![](https://box.kancloud.cn/2016-04-06_5704ccec53210.jpg)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看