Android自定义进度条VIEW(2)

再写一个管理类

public class ProgressViewMag{ private Button start; private ProgressView progressView; private Button restart; public ProgressViewMag(Button start, ProgressView progressView, Button restart) { this.start = start; this.progressView = progressView; this.restart = restart; initView(); } private void initView() { Start(); restart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { progressView.reset(); } }); } public float getTime() { return progressView.getTime(); } public float getMaxProgressSize(){ return progressView.getMaxProgressSize(); } public void Start() { start.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { progressView.setIsStart(false); } if (event.getAction() == MotionEvent.ACTION_DOWN) { progressView.setIsStart(true); } return false; } }); } }

然后是主页

public class MainActivity extends Activity { private Button start; private ProgressView progressView; private Button restart; ProgressViewMag manager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); start = (Button) findViewById(R.id.tv_start); restart = (Button) findViewById(R.id.tv_reset); progressView = (ProgressView)findViewById(R.id.my_progress_view); manager = new ProgressViewMag(start,progressView,restart); } }

这就是实现自定义进度条的全部代码了,写的可能有些糙,如果有错误的地方欢迎给我指出,下次我会更新配上拍摄视频的部分。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/f6c90377add697765e673073e709e85a.html