Progress Dialog in android of our own
How to create a p开发者_开发知识库rogress dialog with blue color background and my own spinner style in android? Please help me out.
Dialog dialog = new Dialog(MainActivity.this, R.style.mydialogstyle);
dialog.setContentView(R.layout.dialogmain);
dialog.setCancelable(false);
ProgressBar pbar = (ProgressBar) dialog.findViewById(R.id.progressBar);
Button btncancel = (Button) dialog.findViewById(R.id.cancelbtn);
btncancel.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
R.layout.dialogmain--->>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:background="#0000FF" android:layout_height="wrap_content">
<ProgressBar style="?android:attr/progressBarStyleHorizontal"
android:progressDrawable="@android:drawable/progress_horizontal"//You can change drawable of spinner
android:layout_marginTop="10dip" android:layout_width="250dip"
android:id="@+id/progressBar" android:layout_height="wrap_content"
android:layout_centerHorizontal="true"></ProgressBar>
<Button android:layout_width="wrap_content" android:background="@drawable/cancel"
android:layout_height="wrap_content" android:text="" android:id="@+id/cancelbtn"
android:layout_marginTop="2dip" android:layout_below="@+id/progressBar"
android:layout_centerHorizontal="true"></Button>
</RelativeLayout>
Res->values-->style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="mydialogstyle" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@null</item>
<item name="android:windowNoTitle">false</item>
</style>
</resources>
精彩评论