Skip to content

Commit

Permalink
进度条
Browse files Browse the repository at this point in the history
  • Loading branch information
Moeyuuko committed Jun 10, 2020
1 parent 4a0355b commit ca2b822
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 2 deletions.
25 changes: 25 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 19
targetSdkVersion 28
versionCode 2
versionName '2.0'
versionName '2.1'

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity2"></activity>
<activity
android:name=".Main9Activity"
android:screenOrientation="portrait" />
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/example/helloandroid/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class MainActivity extends AppCompatActivity {
private Button button12;
private Button button14;
private Button button13;
private Button button16;

private TextView textView;
private TextView textView2;
Expand Down Expand Up @@ -124,6 +125,15 @@ public void onClick(View view) {
startActivity(intent);
}
});
button16 = (Button)findViewById(R.id.button16);
button16.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.i("新建窗口", "进度条");
Intent intent=new Intent(MainActivity.this,MainActivity2.class);
startActivity(intent);
}
});
button13 = (Button)findViewById(R.id.button13);
button13.setOnClickListener(new View.OnClickListener() {
@Override
Expand Down
64 changes: 64 additions & 0 deletions app/src/main/java/com/example/helloandroid/MainActivity2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.example.helloandroid;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;

public class MainActivity2 extends AppCompatActivity {
private Button button_finish_10;
private Button button19;
private Button button20;
private ProgressBar progressBar;
private TextView textView19;
int i = 0;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main10);

button_finish_10 = (Button)findViewById(R.id.button_finish_10);
button_finish_10.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});

button19 = (Button)findViewById(R.id.button19); //-
button20 = (Button)findViewById(R.id.button20); //+
progressBar = (ProgressBar)findViewById(R.id.progressBar);
textView19 = (TextView)findViewById(R.id.textView19);

button19.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(i<=0){
i=0;
}else {
i=i-10;
}
progressBar.setProgress(i);
textView19.setText(String.valueOf(i)+"%");
}
});

button20.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(i>=100){
i=100;
}else {
i=i+10;
}
progressBar.setProgress(i);
textView19.setText(String.valueOf(i)+"%");
}
});
}

}
11 changes: 10 additions & 1 deletion app/src/main/res/layout-land/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@
android:text="剪刀石头布"
android:textSize="18sp" />

<Button
android:id="@+id/button16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="进度条"
android:textSize="18sp" />

<Button
android:id="@+id/button15"
android:layout_width="wrap_content"
Expand Down Expand Up @@ -174,7 +183,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="版本号"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@+id/scrollView2"
app:layout_constraintTop_toTopOf="parent" />

<TextView
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@
android:text="剪刀石头布"
android:textSize="18sp" />


<Button
android:id="@+id/button16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="进度条"
android:textSize="18sp" />

<Button
android:id="@+id/button15"
android:layout_width="wrap_content"
Expand Down
77 changes: 77 additions & 0 deletions app/src/main/res/layout/activity_main10.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity2">


<Button
android:id="@+id/button_finish_10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/back"
app:layout_constraintBottom_toTopOf="@+id/moeyuuko"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<TextView
android:id="@+id/moeyuuko"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="@string/moeyuuko"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<ProgressBar
android:id="@+id/progressBar"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.3" />

<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="@+id/button_finish_10"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/progressBar">

<Button
android:id="@+id/button19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="-10" />

<Button
android:id="@+id/button20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="+10" />
</LinearLayout>

<TextView
android:id="@+id/textView19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="0%"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/progressBar" />

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit ca2b822

Please sign in to comment.