温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Android进度条progressbar

发布时间:2020-06-18 22:56:48 来源:网络 阅读:612 作者:Java大白 栏目:移动开发

xml文件代码部分

<ProgressBar 
    android:id="@+id/firstprobar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:max="200"
    android:progress="100"
    
    />
<Button 
    android:id="@+id/bt1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/firstprobar"
    android:text="前进"
    />
<Button 
    android:id="@+id/bt2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/bt1"
    android:text="后退"
    />

Mainactivity中代码

	private ProgressBar probar;
	private Button bt1;
	private Button bt2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        probar=(ProgressBar)findViewById(R.id.firstprobar);
        probar.setMax(100);
        /*probar.setProgress(20);
        boolean flag=probar.isIndeterminate();
        Toast.makeText(getApplicationContext(), flag+"", Toast.LENGTH_LONG).show();*/
        bt1=(Button)findViewById(R.id.bt1);
        bt2=(Button)findViewById(R.id.bt2);
        FirstLis f=new FirstLis();
        SecondLis s=new SecondLis();
        bt1.setOnClickListener(f);
        bt2.setOnClickListener(s);
    }

    class FirstLis implements OnClickListener{

		@Override
		public void onClick(View v) {
			probar.incrementProgressBy(10);
		}
    	
    	
    }
    class SecondLis implements OnClickListener{

		@Override
		public void onClick(View v) {
			probar.incrementProgressBy(-10);
		}
    	
    	
    }


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI