This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
startActivity(new Intent(Settings.ACTION_LOCALE_SETTINGS)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.toolbarexample; | |
import android.os.Bundle; | |
import android.support.v7.app.ActionBarActivity; | |
import android.support.v7.widget.Toolbar; | |
import android.view.Menu; | |
import android.view.MenuItem; | |
public class MainActivity extends ActionBarActivity { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To hide the navigation bar: | |
[[self navigationController] setNavigationBarHidden:YES animated:YES]; | |
To show it: | |
[[self navigationController] setNavigationBarHidden:NO animated:YES]; | |
See: http://stackoverflow.com/questions/2926914/navigation-bar-show-hide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int getVersionCode() { | |
int versionCode = 0; | |
try { | |
versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; | |
} catch (PackageManager.NameNotFoundException e) { | |
// Huh? Really? | |
} | |
return versionCode; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---- NSDate -> NSString ---- | |
NSDateFormatter *formatter; | |
NSString *dateString; | |
formatter = [[NSDateFormatter alloc] init]; | |
[formatter setDateFormat:@"dd-MM-yyyy HH:mm"]; // Change accordingly. | |
dateString = [formatter stringFromDate:[NSDate date]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) prepareForSegue:(UIStoryboardSegue *) segue sender:(id)sender | |
{ | |
NextViewController *controller = (NextViewController *)segue.destinationViewController; | |
if([segue.identifier isEqualToString:@"mySegueIdentifier"]) { | |
controller.parameter = @"My value to pass to the next controller!"; | |
} else { | |
// Else do something else. | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script> | |
function myFunction(e) { | |
if(e.keyCode == 97 || e.keyCode == 65) { | |
document.getElementById("textChange").innerHTML = "A or a was pressed!"; | |
} else if (e.keyCode == 66 || e.keyCode == 98) { | |
document.getElementById("textChange").innerHTML = "B or b was pressed!"; | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private int getScreenWidth(Context context) { | |
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); | |
Display display = wm.getDefaultDisplay(); | |
DisplayMetrics metrics = new DisplayMetrics(); | |
display.getMetrics(metrics); | |
int width = metrics.widthPixels; | |
return width; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In XML add this to the ListView: | |
android:listSelector="@android:color/transparent" | |
In code add this to the ListView: | |
myListView.setSelector(android.R.color.transparent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In code: | |
getListView().setDivider(null); | |
getListView().setDividerHeight(0); | |
In XML: | |
android:divider="@null" | |
android:dividerHeight="0dp" |