Latest Entries »

@interface XTableView : UITableView {
}
@end

@implementation XTableView


- (BOOL) allowsHeaderViewsToFloat {
	return NO;
}
- (BOOL) allowsFooterViewsToFloat {
	return NO;	
}
@end

- (void)onChangedOrientation:(NSNotification *)notification {
	UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
	if ((orientation == UIDeviceOrientationLandscapeLeft
|| orientation == UIDeviceOrientationLandscapeRight)) {
		// ex:layoutForLandscape
	}
	else if (orientation == UIDeviceOrientationPortrait) {
		//  ex:layoutForPortrait
	}
}

- (void)viewDidLoad {
    [super viewDidLoad];
	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onChangedOrientation:)
								name:UIDeviceOrientationDidChangeNotification
								object:nil];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
	[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
}

- (void)viewWillDisappear:(BOOL)animated {
	[super viewWillDisappear:animated];
	[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];

}

// DON'T FORGET ENABLING IT!
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

AssetManager mgr = getContext().getAssets();
InputStream in = mgr.open("help.html");
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
or
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
<ListView android:id="@+id/ResultListView"
android:cacheColorHint="@android:color/white">



Caller Activity

/* Start Activity */
	public void onClick(View v) {
		Intent intent = new Intent(Intent.ACTION_VIEW);
		intent.setClassName("com.thinoo.ActivityTest", "com.thinoo.ActivityTest.NewActivity");
		startActivityForResult(intent,90);
	}
/* Called when the second activity's finished */
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         switch(requestCode) {
            	case 90:
            	 if (resultCode == RESULT_OK) {
	            	 Bundle res = data.getExtras();
	            	 String result = res.getString("param_result");
	            	 Log.d("FIRST", "result:"+result);
            	 }
            	break;
         }
    }

Callee Activity


    private void finishWithResult()
    {
       Bundle conData = new Bundle();
       conData.putString("results", "Thanks Thanks");
       Intent intent = new Intent();
       intent.putExtras(conData);
       setResult(RESULT_OK, intent);
       finish();
    }
- (void) convertThread {
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
	

	[self performSelectorOnMainThread:(@selector(updateProgressiveView)) withObject:nil waitUntilDone:NO];
    [pool release];
}


- (void) onStart:(id)sender {
	[self performSelectorInBackground:(@selector(convertThread)) withObject:nil];
}


int viewIndex = [[superView subviews] indexOfObject:targetView];

Add preprocessor DEBUG in build option for debug mode.

#ifdef DEBUG
	#define XLog(fmt, ...) NSLog((@"%s (%d) " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
	#define XLog(...)
#endif

Usages of XLog is exactly same as NSLog.

In your .plist file, add the key named
“Application does not run in background” (UIApplicaionExitsOnSuspend).

Make it YES!