ProgressBar
属性:style:“?android:attr/peogressBarStyleHorizontal” //设置样式(圈大 圈小 水平样式)
progress:20 //当前进度
max:100 //最大进度
min:0 //最小进度
SeekBar
属性:同上
事件:onSeekBarChangeLinsener //三个方法:1.进度改变 带参数progress 2.开始拖拉 3.停止拖拉
RatingBar
属性:android:numStarts = “5” //星星数量
android:min = “0”;
android:rating = “0.3” //当前进度
android:stepSize = “0.5” //步数(一颗星几次点完)
assets
方法:getAssets(); //获得assets文件夹
open(文件名) //打开指定文件 得到inputStream对象
页面跳转
Intent intent = new Intent(LoadFileActivity.this,Main)
注意事项
主线程又叫UI线程只能更新UI
runonUiThread(线程1对象) //将线程1发送到主线程执行
代码实现
// An highlighted block
<LinearLayout
android:id="@+id/activity04"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="@+id/dq"
android:layout_width="match_parent"
android:layout_height="200dp" />
<ProgressBar
android:id="@+id/jdt"
android:layout_width="match_parent"
android:layout_height="40dp"
style="?android:attr/progressBarStyleHorizontal"
android:max="742" />
<Button
android:id="@+id/ksxz"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="开始下载"/>
</LinearLayout>
//JAVA代码
package com.example.tx.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class allActivity extends AppCompatActivity {
Button btn1;
Button btn2;
Button btn3;
Button btn4;
Button btn5;
LinearLayout linearLayout1;
LinearLayout linearLayout2;
LinearLayout linearLayout3;
LinearLayout linearLayout4;
TextView text1;
ImageView imageView1;
RadioButton radioButton1;
RadioButton radioButton2;
RadioButton radioButton3;
RadioButton radioButton4;
TextView textView01;
TextView textView02;
TextView textView03;
TextView textView04;
TextView textView05;
TextView textView06;
ImageView yejian;
ImageView qiandao;
ImageView touxiang;
Button begin;
TextView wenbenyu;
ProgressBar jindutiao;
StringBuffer stringBuffer = new StringBuffer();
int sum = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_all);
wenbenyu = findViewById(R.id.dq);
jindutiao = findViewById(R.id.jdt);
linearLayout1 = findViewById(<