Adding Image to a UIImageView using Image URL

By | March 14, 2011

Hi, Sometimes you need to add Image to a UIImageView from the URL of the image you got. In that case, this is how you can add image to the UIImageView. NSString *picURL= @”http://photobucket.com/yourImage.gif”; NSData *picData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:mapURL]]; UIImage* picture = [[UIImage alloc] initWithData:picData]; [pictureView setImage:picture]; [picData release]; [picture release]; Here, pictureView is… Read More »

How to create a new Virtual SD card in emulator in ANDROID? How to start emulator with the created SDCard?

By | March 13, 2011

OK The first question is 1. How to create a new Virtual SD card in emulator in ANDROID? Many times we may have not enough memory for our application to run on the emulator. So what we do? One method is to create new virtual device with more memory. Another method is to extend the… Read More »

How to create a scrolling ListView in android?

By | March 12, 2011

ListView is like a tableView in iPhone or iOS . In this example i will show you how to add a String Array in to the ListView and also make the listView Scrollable. First the xml file . Here the line android:scrollbars=”vertical” will make the scrolling vertically Now the java file The screen will be… Read More »

How to read a folder in the assets directory and read files from it in android?

By | March 12, 2011

File reading is important in android. For the put the files in the assets folder. We can able to read foldername filename Contents of the file First we read the name of the folder. “folder_array” contains all the names of the folder Then if the path is set to Then the list of file name… Read More »

Copying a Sprite Image to another Sprite in Cocos2D

By | March 11, 2011

Hi, Suppose you want to copy a sprite image to another new sprite while using cocos2D. What you do? See the following code… Let oldSprite be your first sprite CCSprite *oldSprite = [CCSprite spriteWithFile:@”ImgOne.png”]; And newSprite be your second sprite CCSprite *newSprite = [CCSprite spriteWithTexture:[oldSprite texture]]; That’s it! Done! Now newSprite too contain ImgOne as… Read More »

Playing sound on the Mac Desktop in Objective C.

By | March 11, 2011

There are different ways for playing sound on the Mac in Objective C. Let’s look at some of the methods.. 1. Play by filename. NSSound *mySound = [NSSound soundNamed:@”sound”]; if you have no file named “sound” in your application’s main bundle, then it will return nil. 2. Play by pathName sound = [[NSSound alloc] initWithContentsOfFile:@”/Volumes/Audio/sound.aiff”… Read More »

Delete a substring in Objective C, Iphone , Mac………….

By | March 10, 2011

This code snippet deletes a substring from a original string.. /** initialize two strings **/ NSString *string = @”This is heaven”; NSString *part = @”heaven”; /** Get the range of the substring in the original string **/ NSRange range = [string rangeOfString:part]; /** Delete the substring from the original string **/ [string deleteCharactersInRange:range]; Please leave… Read More »

ToolTip Sound in Adobe AIR/FLEX…

By | March 10, 2011

Sometimes we may need to have a sound when we hover over something, i.e when a tooltip appears. Actually this can be done easily by adding an eventListener to the corresponding control. Take a look at the example. This line is the important line. myLabel.addEventListener(ToolTipEvent.TOOL_TIP_SHOW, myListener); The function myListener gets called when we hover over… Read More »

AlertView with textbox in iPhone, Objective C.

By | March 9, 2011

Often we see alerts with text message or title in it. But actually we can customize alerts. We can place any views inside it. We can place a textView(TextField) , imageView etc in it. Take a look at this simple example that places a textbox inside an alertView. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@”Title goes… Read More »

Using GridView in ANDROID….

By | March 9, 2011

GridViews are those in which you can arrange elements in a two dimensional grid. It is what you see in the gallery where images are arranged. Here images are arranged in a two dimensional grid. Copy the below code and save it as “MyGridView.java” Now create another file named “Images.java” and copy the below code… Read More »

Android TableLayout

By | March 9, 2011

In android there are different layouts and we often confuse about which one to use. Even if we select one, it is little complicated. So this tutorials is to show you about the TableLayout Here i first created linear Layout in which a Table Layout is added Here you can see that the first row… Read More »

How to Disable Right Click on HTML page using jQuery ?

By | March 8, 2011

Hi, In some special cases you may need to disable the Right Click option on HTML page you are using. An easy way to do it using jQuery is follows. Use the following code in the HTML page where you want to disable Right Click. $(document).ready(function(){ $(document).bind(“contextmenu”,function(e){ return false; }); }); 🙂

How to make gear joint in Box2D, iPhone?

By | March 7, 2011

Gear joints are one of the real specialities of Box2D. By creating gear joints between two bodies you can actually simulate a real world gear. For creating a gear joint you need two bodies connected by a revolute or prismatic joint. The below code creates two bodies in the shape of a circle which is… Read More »

Swing JPanel with background image

By | March 7, 2011

This code add an image to Jpanel. JPanel panel1 = new JPanel(); JFrame recursion_frame = new JFrame(); BackgroundPanel stack_image1 = new BackgroundPanel(“Recursion.jpg”); panel1.setLayout(null); panel1.setLayout(new BorderLayout()); panel1.setBackground(Color.lightGray); panel1.setVisible(true); recursion_frame.setContentPane(panel1); ///adding to panel… recursion_frame.getContentPane().add(stack_image1); //adding image to panel…

Position swing window in center of the screen

By | March 7, 2011

In some case we need to position the window in the center of the screen . The same effect can be achieved by hard coding the center points .But in that case the window position change when the screen resolution changes This code will position the window in center irrespective of different screen resolutions public… Read More »

What is Objective C Keyword id ?

By | March 6, 2011

Hi, Objective C uses a special keyword ‘id’. Let’s see what it is. Objective C -id- is actually a ‘pointer to an object’. That is ‘id’ can hold a pointer to any objective c object. It doesn’t matter the object’s class. eg: NSString *myString = @”Coderz Heaven!”; id newString; NSString *tempString; newString=myString; tempString=newString; That’s it!… Read More »