Uploading an Activity using ProgressBar

0

ProgressBar XML Code

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
    android:layout_width="match_parent">

    <ProgressBar
    android:layout_height="11px"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="300px"
    android:id="@+id/load"
    android:layout_centerInParent="true"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="52px"/>

</RelativeLayout>

ProgressBar code in Java

package game.app;

import android.app.*;
import android.os.*;

public  class LoadActivity extends  Activity {

  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.loadlayout);
  }
}

Activity that ProgressBar will load

package game.app;

import android.app.Activity;
import android.os.Bundle;
import android.widget.*;
import android.view.*;
import android.view.View.*;
import android.content.*;

public class MenuActivity extends Activity {

  private Button btiniciar;

  @Override

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.menulayout);

    btiniciar = (Button) findViewById(R.id.btiniciar);
    btiniciar.setOnClickListener(new View.OnClickListener(){
      public void onClick(View v) {

        @Override

        Intent it = new Intent(MenuActivity.this,LoadActivity.class);
        startActivity(it);
        finish();
      }
    });

    Button btconfig = (Button) findViewById(R.id.btconfig);
    btconfig.setOnClickListener(new View.OnClickListener(){
      public void onClick(View argO) {


      }
    });
  }
}
    
asked by anonymous 27.07.2018 / 07:54

1 answer

0

The ProgressBar is a UI element that indicates the progress of an operation; in this action you are doing there is no action that requires ProgressBar.

An example where you can use ProgressBar is to use AsyncTasks to load API data, image download and etc ... unless to simulate the progress you use some postDelayed by setting a time to simulate a delay in screen transition.

 btiniciar = (Button) findViewById(R.id.btiniciar);
    btiniciar.setOnClickListener(new View.OnClickListener(){
      public void onClick(View v) {

                //MOSTRAR PROGRESS
                final Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                     //ESCONDER PROGRESS
                       Intent it = new Intent(MenuActivity.this,LoadActivity.class);
                       startActivity(it);
                       finish();
                    }
                }, 2000);
      }
    });
    
27.07.2018 / 20:53