直播平臺軟體開發,讓原本沒有進度條的頁面顯示進度條

zhibo系統開發發表於2022-04-25

直播平臺軟體開發,讓原本沒有進度條的頁面顯示進度條

程式碼如下:

btn1.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
                 switch (view.getId()){
                     case R.id.btn1:
                     /*mn1.setBackgroundResource(R.drawable.mn2);
break;*/
                         mn1.setBackgroundResource(R.drawable.mn2);
                         if (p1.getVisibility()== GONE) {
                             p1.setVisibility(View.VISIBLE);
                         } else{
                             p1.setVisibility(GONE);
                         }
                         break;
                 }
             }
         });

MainActivity.java

package com.example.firstcode;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
 
import static android.view.View.GONE;
 
public class MainActivity extends AppCompatActivity {
private ImageView mn1,mn2;
private ProgressBar p1;
   private Button btn1;
    /*@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }*/
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn1=findViewById(R.id.btn1);
 
       p1=findViewById(R.id.p1);
        mn1=findViewById(R.id.mn1);
         btn1.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
                 switch (view.getId()){
                     case R.id.btn1:
 
                     /*mn1.setBackgroundResource(R.drawable.mn2);
break;*/
                         mn1.setBackgroundResource(R.drawable.mn2);
 
                         if (p1.getVisibility()== GONE) {
                             p1.setVisibility(View.VISIBLE);
                         } else{
                             p1.setVisibility(GONE);
 
                         }
                         break;
 
 
                 }
             }
         });
         /*btn1.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view1) {
                 switch (view1.getId()){
                     case R.id.btn1:
                 if (p1.getVisibility()== GONE) {
                     p1.setVisibility(View.VISIBLE);
                 } else{
                     p1.setVisibility(GONE);
                     }
                 break;
                 }
                 }
         });*/
       // btn1=findViewById(R.id.btn1);
        /*btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent =new Intent(MainActivity.this,Main2Activity.class);
                startActivity(intent);
            }
        });*/
       /*btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent =new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("));
                startActivity(intent);
            }
        });*/
 
        /*btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
            Intent intent = new Intent (Intent.ACTION_DIAL);
                    intent.setData(Uri.parse("tel:10086"));
            startActivity(intent);
            }
        });*/
 
       /* btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String data ="hello Main2Activity";
                Intent intent =new Intent(MainActivity.this,Main2Activity.class);
                intent.putExtra("extra_data",data);
                startActivity(intent);
            }
        });*/
    }
 
}


以上就是 直播平臺軟體開發,讓原本沒有進度條的頁面顯示進度條,更多內容歡迎關注之後的文章


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2888625/,如需轉載,請註明出處,否則將追究法律責任。

相關文章