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 void setAppVersion(TextView textView) { | |
try { | |
textView.setText("Version: " + getContext().getPackageManager().getPackageInfo(getContext().getPackageName(), 0).versionName); | |
} catch (NameNotFoundException e) { | |
// Nothing to see here - move along. We just eat this exception, because we can't use it for anything... | |
} | |
} |
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
Horizontal line | |
<View | |
android:layout_width="1dip" | |
android:layout_height="fill_parent" | |
android:background="#FF0000FF" /> | |
Vertical line | |
<View |
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 class MainActivity extends Activity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
// Getting the ImageView containing the picture to make round. | |
ImageView profilePic = (ImageView) findViewById(R.id.myImageView); | |
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
/* | |
* System Versioning Preprocessor Macros | |
*/ | |
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) | |
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) | |
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) | |
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) | |
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending) |
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
Goes in the drawable-folder | |
list_selector.xml: | |
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
<item android:drawable="@color/transparent" android:state_pressed="false" android:state_selected="false"/> | |
<item android:drawable="@color/semi_transparent" android:state_pressed="true"/> | |
<item android:drawable="@color/semi_transparent" android:state_pressed="false" android:state_selected="true"/> |
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" |
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
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
<!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
- (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. | |
} | |
} |
OlderNewer