Custom Dialog, android custom dialog
Yes. When the first button is pressed, a custom Dialog is displayed. The second and third buttons are ProgressBar, but the style is changed.
The first ProgressBar is in the clockwise direction and the second is in the clockwise direction.
The main code is as follows:
Package com. demo. sb. main; import com. demo. suibian. r; import android. app. activity; import android. app. alertDialog; import android. OS. bundle; import android. view. display; import android. view. view; import android. view. view. onClickListener; import android. view. windowManager; import android. widget. button; import android. widget. toast; public class Activity_Dialog extends Activity implements OnClickListener {private Button btn_dialog; @ Override protected void onCreate (Bundle savedInstanceState) {// TODO Auto-generated method stub super. onCreate (savedInstanceState); setContentView (R. layout. activity_dialog); btn_dialog = (Button) findViewById (R. id. btn_dialog); btn_dialog.setOnClickListener (this);} @ Override public void onClick (View arg0) {// TODO Auto-generated method stub switch (arg0.getId () {case R. id. btn_dialog: initDialog (); break; default: break;} private void initDialog () {// TODO Auto-generated method stub AlertDialog. builder builder = new AlertDialog. builder (this); builder. setCancelable (false); final AlertDialog dialog = builder. create (); View view = View. inflate (this, R. layout. item_dialog, null); dialog. setView (view, 0, 0, 0, 0); Button btnCancel = (Button) view. findViewById (R. id. btn_cancel); Button btnOk = (Button) view. findViewById (R. id. btn_ OK); btnOk. setOnClickListener (new View. onClickListener () {@ Override public void onClick (View arg0) {// TODO Auto-generated method stub Toast. makeText (Activity_Dialog.this, "queding", Toast. LENGTH_SHORT ). show (); dialog. dismiss () ;}}); btnCancel. setOnClickListener (new View. onClickListener () {@ Override public void onClick (View arg0) {// TODO Auto-generated method stub dialog. dismiss () ;}}); dialog. show ();/*** change the position where the Dialog is displayed on the screen */WindowManager manager = getWindowManager (); Display display = manager. getdefadisplay display (); android. view. windowManager. layoutParams params = dialog. getWindow (). getAttributes (); params. height = (int) (display. getHeight () * 0.4); params. width = (int) (display. getWidth () * 0.75); params. x = 10; params. y = 150; dialog. getWindow (). setAttributes (params );}}
Layout File
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <Button android:id="@+id/btn_dialog" android:layout_width="match_parent" android:layout_height="wrap_content" /> <ProgressBar android:id="@+id/pb_dialog_one" android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center" android:indeterminateDrawable="@drawable/indeterminate_drawable" android:indeterminateDuration="1000" /> <View android:layout_width="match_parent" android:layout_height="2dp" android:layout_marginTop="5dp" android:layout_marginBottom="5dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:background="#000" /> <ProgressBar android:id="@+id/pb_dialog_two" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:background="#2000" android:indeterminateDrawable="@drawable/custom_progress" > </ProgressBar></LinearLayout>
<?xml version="1.0" encoding="utf-8"?><rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="360" android:pivotX="50%" android:pivotY="50%" android:drawable="@drawable/pic" android:toDegrees="0"> </rotate>
<?xml version="1.0" encoding="utf-8"?><rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="0" android:pivotX="50%" android:pivotY="50%" android:toDegrees="360" > <shape android:innerRadius="12dp" android:shape="ring" android:thickness="3dp" android:useLevel="false" > <gradient android:centerColor="#3f00" android:endColor="#f00" android:startColor="#fff" /> </shape></rotate>