资源预览内容
亲,该文档总共2页全部预览完了,如果喜欢就下载吧!
资源描述
图片切换利用 SeekBar 滑动显示Activity 程序package org.lxh.seekbardemo03;import android.os.Bundle;import android.app.Activity;import android.view.Menu;import android.widget.ImageView;import android.widget.SeekBar;import android.widget.SeekBar.OnSeekBarChangeListener;public class MainActivity extends Activity private ImageView pic=null;private SeekBar seekbar=null;private int picData=new intR.drawable.pic_0,R.drawable.pic_1,R.drawable.pic_2,R.drawable.pic_3,R.drawable.pic_4,R.drawable.pic_5,R.drawable.pic_6,;Overrideprotected void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);this.pic=(ImageView)super.findViewById(R.id.pic);this.seekbar=(SeekBar)super.findViewById(R.id.seekbar);this.seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListenerImpl();private class OnSeekBarChangeListenerImpl implements OnSeekBarChangeListenerOverridepublic void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) / TODO Auto-generated method stubMainActivity.this.pic.setImageResource(MainActivity.this.picDataseekBar.getProgress();/修改显示的图片Overridepublic void onStartTrackingTouch(SeekBar seekBar) / TODO Auto-generated method stub Overridepublic void onStopTrackingTouch(SeekBar seekBar) / TODO Auto-generated method stubOverridepublic boolean onCreateOptionsMenu(Menu menu) / Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.activity_main, menu);return true;Xml 程序显示程序很简单.是一个小小的例子
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号