[ACCEPTED]-Android Activity Indicator?-android-activity
The most direct equivalent of the iOS Activity 6 Indicator in Android is the ProgressBar
but set to 5 indeterminate. So you can drop the view 4 into your layout and it will provide you 3 with a spinning animation.
<ProgressBar
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/ctrlActivityIndicator"
android:indeterminateOnly="true"
android:keepScreenOn="true"
/>
You could use 2 this to indicate some background activity 1 to the user.
do some thing like this
ProgressDialog mDialog = new ProgressDialog(getApplicationContext());
mDialog.setMessage("Please wait...");
mDialog.setCancelable(false);
mDialog.show();
0
There are two other ways of showing activity 7 indicator without using modal ProgressDialog.
You 6 can use ImageView in your layout and apply 5 animation to it. Refer developer's site.
public void startAnimation() {
// Create an animation
RotateAnimation rotation = new RotateAnimation(
0f,
360f,
Animation.RELATIVE_TO_SELF,
0.5f,
Animation.RELATIVE_TO_SELF,
0.5f);
rotation.setDuration(1200);
rotation.setInterpolator(new LinearInterpolator());
rotation.setRepeatMode(Animation.RESTART);
rotation.setRepeatCount(Animation.INFINITE);
// and apply it to your imageview
findViewById(R.id.myActivityIndicator).startAnimation(rotation);
}
Or you can use xml-drawable 4 to describe a background image, which will 3 have some rotating animation:
Firstly describe 2 a drawable (in i.e. /res/drawable/my-indicator.xml)
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/spinner_black_76"
android:pivotX="50%"
android:pivotY="50%"
android:framesCount="12"
android:frameDuration="100" />
Then 1 set it at some view's background
public class Mp3cutterActivity extends Activity {
MP3Class mp3obj = null;
TextView tv;
MP3Class mp3classobj = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Context thiscontext = this.getApplicationContext();
mp3classobj = new MP3Class(thiscontext);
setContentView(R.layout.main);
Button btn = (Button)findViewById(R.id.startbutton);
tv = (TextView)findViewById(R.id.textview1);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//show a wait indicator as well as the function that calls walkSdcard
try {
new SearchSdCard(Mp3cutterActivity.this).execute();
// copyProtector.doCopyProtection();
} catch (Exception e) {
System.out.println("in search SD card " + e.getMessage());
}
}
private void domp3stuff() {
// TODO Auto-generated method stub
}
});
}
}
class SearchSdCard extends AsyncTask<String, Void, Boolean> {
Context context;
public ProgressDialog dialog;
public SearchSdCard(Activity activity) {
this.context = activity;
}
protected void onPreExecute() {
dialog = new ProgressDialog(context);
dialog.setMessage("wait for a moment...");
dialog.show();
}
@Override
protected Boolean doInBackground(String... params) {
// TODO Auto-generated method stub
boolean retval = true;
mp3classobj.searchSdCard();
return retval;
}
@Override
protected void onPostExecute(Boolean result) {
// TODO Auto-generated method stub
if (dialog.isShowing()) {
dialog.dismiss();
tv.setText("mp3 cutter is an app which cuts down a chunk of memory \nfrom your sdcard by \ndeleting the .mp3 files and more \nyou were made a BAKRA :-)");
if(!result){
tv.setText("error occured !!");
}
}
}
//refer below comment for the MP3class.java file details
}
0
Activity indicator is nothing but it is 6 known as progress dialog. You can create 5 programmatically.Numbers of tutorials are 4 available, Search how to create progress 3 dialog/ProgressBar
ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setMax(100);
progressDialog.setMessage("Its loading....");
progressDialog.setTitle("ProgressDialog bar example");
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
or
progressDialog.setProgressStyle(ProgressDialog.STYLE_CIRCULAR);
or you can create it by 2 using xml , set the visibility visible once task 1 get completed set visibility gone
<ProgressBar
android:id="@+id/loading_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:indeterminateTintMode="src_atop"
android:indeterminateTint="@color/grey"
android:layout_gravity="center" />
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.