Friday, December 7, 2012

ScrollView with Button on Bottom in Android


ScrollView with Button on Bottom in Android

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_height="wrap_content" android:layout_width="fill_parent">
     <TextView android:id="@+id/TextView01" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="This text view should act as header  " />
     <ScrollView android:layout_marginBottom="50dip" android:id="@+id/ScrollView01" android:layout_height="wrap_content" android:layout_width="fill_parent">
          <RadioGroup android:id="@+id/RadioGroup01" android:layout_width="wrap_content" android:layout_height="wrap_content">
               <RadioButton android:id="@+id/RadioButton01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton11" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />       
          </RadioGroup>
     </ScrollView>
     <RelativeLayout android:layout_marginTop="-50dip" android:gravity="bottom" android:layout_height="wrap_content" android:layout_width="fill_parent">
        <TableLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="1">
         <TableRow>
        <Button android:id="@+id/Button01" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="One"/>
        <Button android:id="@+id/Button01" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Two" android:layout_gravity="center_vertical"/>
        <Button android:id="@+id/Button01" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Three" android:layout_gravity="right"/>
      </TableRow>
      </TableLayout>
     </RelativeLayout>
</LinearLayout>

Thursday, November 22, 2012

Send Email with Attachment in iphone

Send Email with Attachment in iphone

1) In Xcode 4 goto the build phases tab for your target. Make sure you see MessageUI.framework. If it's not there click + to add a new framework.

2)In your interface file


#import <MessageUI/MFMailComposeViewController.h>


@interface YourViewController : UIViewController <MFMailComposeViewControllerDelegate> 


3)Add this Method


-(void)displayComposerSheet
{
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;
    [picker setSubject:@"Check My Image!"];

    // Set up recipients
    // NSArray *toRecipients = [NSArray arrayWithObject:@"first@example.com"];
    // NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com", @"third@example.com", nil];
    // NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"];

    // [picker setToRecipients:toRecipients];
    // [picker setCcRecipients:ccRecipients];  
    // [picker setBccRecipients:bccRecipients];

    // Attach an image to the email
    UIImage *myImage = YourImage;
    NSData *myData = UIImagePNGRepresentation(
myImage);
    [picker addAttachmentData:myData mimeType:@"image/png" fileName:@"
myImage.png"];

    // Fill out the email body text
    NSString *emailBody = @"My Pic";
    [picker setMessageBody:emailBody isHTML:NO];
    [self presentModalViewController:picker animated:YES];

    [picker release];
}


4) Implement the delegate method

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{  
    // Notifies users about errors associated with the interface
    switch (result)
    {
        case MFMailComposeResultCancelled:
            NSLog(@"Result: canceled");
            break;
        case MFMailComposeResultSaved:
            NSLog(@"Result: saved");
            break;
        case MFMailComposeResultSent:
            NSLog(@"Result: sent");
            break;
        case MFMailComposeResultFailed:
            NSLog(@"Result: failed");
            break;
        default:
            NSLog(@"Result: not sent");
            break;
    }
    [self dismissModalViewControllerAnimated:YES];
}




Sunday, November 18, 2012

Recieve SMS and show it in Activity as DialogBox

Recieve SMS and show it in Activity as DialogBox


Source Code

Thursday, November 15, 2012

Take SnapShot and save in gallery in iphone

Take SnapShot and Save in gallery in iphone

canvasView is UIView. if you want to take snapshot of whole screen use self.view.

    UIGraphicsBeginImageContext(canvasView.frame.size);
    [canvasView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

Wednesday, November 14, 2012

Drag UIImageVIew ( touch Event ) in iphone


Drag UIImageVIew ( touch Event ) in iphone

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
blockView.center = location;   // blockView = UIimageView which you want to drag
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[self touchesBegan:touches withEvent:event];
}

Thursday, November 8, 2012

Custom Color in Iphone and Core Plot

Custom Color in Iphone and Core Plot



Add Custom Color in Iphone

[UIColor colorWithRed:0.47 green:0.77 blue:0.37 alpha:1.0



Add Custom Color in Core-Plot

[CPTColor colorWithComponentRed:0.47 green:0.77 blue:0.37 alpha:1.0];

Thursday, November 1, 2012

Merge two NSDictionary in one NSDictionary ( if keyvalues are same )

Merge two NSDictionary in one NSDictionary ( if keyvalues are same )


NSMutableDictionary *combined = [your_nsdictionary mutableCopy];
    for(NSString *key in [combined allKeys])
    {
        NSString *breakfastDate = [your_nsdictionary valueForKey:key];
        NSString *dinnerDate = [your_nsdictionarytwo objectForKey:key];
        if(dinnerDate){
            [combined setObject:[NSString stringWithFormat:@"%@,%@",breakfastDate, dinnerDate] forKey:key];
            } else {
                [combined setObject:[NSString stringWithFormat:@"%@,0",breakfastDate] forKey:key];
                }
    }
    NSLog(@"Combine %@",combined);