Tuesday, December 4, 2012

Android:iPhone like two field Segment Control

Hi fellas


What would we use here is use a Toggle button from android and will apply style on it.

Step 1:

Toggle button in your xml:

  <ToggleButton
                        android:id="@+id/toggleButton"
                        style="@style/style_toggle_button"
                        android:layout_width="130dp"
                        android:layout_height="35dp"
                        android:layout_marginLeft="10dp" />



Step 2 :
Style in /Value

<style name="style_toggle_button">
        <item name="android:background">@drawable/conv_fee_toggle_drawable</item>
        <item name="android:checked">true</item>
        <item name="android:textOff"></item>
        <item name="android:textOn"></item>
        <item name="android:text"></item>
    </style>



Step 3:
conv_fee_toggle_drawable in Drawable

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/percentage" android:state_checked="true"></item>
    <item android:drawable="@drawable/fixed" android:state_checked="false"></item>
</selector>


 Thats it Just place two images percentage on from iphone and fixed on from iphone

Thursday, June 14, 2012

Android : iphone red delete button

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

    <gradient
        android:angle="90"
        android:centerY="0.5"
        android:endColor="#D9787F"
        android:startColor="#BD1421" />

    <stroke
        android:width="1dp"
        android:color="#3F3F3F" />

    <corners android:radius="5sp" />

    <padding
        android:bottom="5dp"
        android:left="5dp"
        android:right="5dp"
        android:top="5dp" />

</shape>

Tuesday, June 12, 2012

Android: Facebook profile Image to ImageView

try {
img_value = new URL("http://graph.facebook.com/"+userId+"/picture?type=large");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Bitmap mIcon1 = null;
try {
mIcon1 = BitmapFactory.decodeStream(img_value.openConnection().getInputStream());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
imageUserProfile.setImageBitmap(mIcon1);

Monday, May 7, 2012

Android Set Text Color at Runtime (Code)

So it is pretty simple..
just

Step1 . Create color.xml  under  res/values in you android project
             with color name and color code

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
          <color name="Red">#E41B17</color>
          <color name="Blue">#A5D4FE</color>
          <color name="Purple">#9172EC</color>
    </resources>

Step 2 . Now in your activity

        txRed.setTextColor(getResources().getColor(R.color.Red));
        txBlue.setTextColor(getResources().getColor(R.color.Blue));
        txPurple.setTextColor(getResources().getColor(R.color.Purple));

Wednesday, May 2, 2012

Generating Key for Android Map view

This is for windows users

Step 1. Open CMD

Step 2  run  cd   C:\Program Files\Java\jdk1.5.0_10\bin   (please check your java version)

Step 3 now run the following command
         
keytool -list -keystore "C:/Documents and Settings/<"your user name here">/.android/debug.keystore"

Step 4 It will ask for password press enter leave it blank

Step 5 the certificate's MD5 fingerprint will be generated copy it
 
Step 6 Go to the following link
       Google Maps Signup Page
                    
                
Step 7 paste you MD5 fingerprint here and click on generate API Key

Tuesday, March 27, 2012

Android Reboot to recovery if volume buttons are not working

Step 1. Power Off your android phone
Step 2. Open FastBoot (for eg. in HTC Desire press Back and Power Button )
Step 3. Open CMD on your windows machine, move to sdk/platform-tools. where adb and fastboot exe are  
            present
Step 4. Run the following command
                   
                                fastboot oem gencheckpt

Done ! your phone will reboot to recovery

Source :XDA