How to make a Please Wait Dialog using UIAlertView without Buttons in iOS

Standard

If you’ve ever wanted to show a simple “please wait” dialog without resorting to a custom view, UIAlertView is a good option, and is even more appropriate if you customize the alert such that no buttons are shown.

In the figure below you can see how a simple alert can be shown (sans buttons) while you are busy doing some other system activity (reading/writing files, etc).

How to create a toggle button with custom image and no text in Android

Standard

Create a file ic_toggle.xml in your res/drawable folder

<selector xmlns:android="http://schemas.android.com/apk/res/android">
 <item
 android:state_checked="false"
 android:drawable="@drawable/ic_slide_switch_off" />
 <item
 android:state_checked="true"
 android:drawable="@drawable/ic_slide_switch_on" />
</selector>

Here @drawable/ic_slide_switch_on & @drawable/ic_slide_switch_off are images you create.

Then create another file in the same folder, name it ic_toggle_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+android:id/background" 
 android:drawable="@android:color/transparent" />
<item android:id="@+android:id/toggle"
 android:drawable="@drawable/ic_toggle" />
</layer-list>

Now add to your custom theme, (if you don’t have one create a styles.xml file in your res/values/folder)

<style name="Widget.Button.Toggle" parent="android:Widget">
 <item name="android:background">@drawable/ic_toggle_bg</item>
 <item name="android:disabledAlpha">?android:attr/disabledAlpha</item>
</style>

<style name="toggleButton" parent="@android:Theme.Black">
<item name="android:buttonStyleToggle">@style/Widget.Button.Toggle</item>
<item name="android:textOn"></item>
<item name="android:textOff"></item>

This creates a custom toggle button for you.
Now use the custom style and background in your view.

<ToggleButton
 android:id="@+id/toggleButton"
 android:layout_width="wrap_content"
 android:layout_height="match_parent"
 android:layout_gravity="right"
 style="@style/toggleButton"
 android:background="@drawable/ic_toggle_bg"
 />

How to hide/unhide label, textfield and disable button in Objective-C

Standard

Here is the answer for hiding:

[self.label1 setHidden:TRUE];

and here is the answer for disabling:

[self.btnOutlet setEnabled:FALSE];

setCompoundDrawables() doesn’t display the Button Drawable

Standard

Image is blank because it hasn’t got specified bounds. You may use setCompoundDrawables() but before you should specify image’s bounds, using Drawable.setBounds() method:

Drawable d = getResources().getDrawable(R.drawable.ic_action_selector);
d.setBounds(0, 0, 128, 128);
btnRegistery.setCompoundDrawables(null, d, null, null);