Skip to content

Instantly share code, notes, and snippets.

View mako34's full-sized avatar
💭
automagickally

manuelBetancurt mako34

💭
automagickally
View GitHub Profile
@mako34
mako34 / android fragment button listener
Created September 13, 2013 02:43
Android button listener for a fragment, note the return!
public class PhoneValidateView extends SherlockFragment{
private Button btnNewEmpresa;
private LinearLayout lLayoutFrgValidate;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
//get the layou8t
lLayoutFrgValidate=(LinearLayout) inflater.inflate(R.layout.activity_validate_phone, container, false);
@mako34
mako34 / android uiElement animation
Created September 13, 2013 07:14
android animation of ui element
mAnimation = new TranslateAnimation(0, -720, 0, 0); //use size of screen!
//mAnimation = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta)
mAnimation.setDuration(300);
mAnimation.setFillAfter(true);
mAnimation.setRepeatCount(0);
//mAnimation.setRepeatMode(Animation.REVERSE);
myUIelement.setAnimation(mAnimation);
myUIelement.startAnimation(mAnimation);
@mako34
mako34 / params hack programatically frame
Created September 16, 2013 23:56
Change "frame" of UI element on android
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) listViewSubItem.getLayoutParams();
params.leftMargin = 300;
//params.topMargin = 10;
listViewSubItem.setLayoutParams(params);
@mako34
mako34 / gide show UI elements
Created September 17, 2013 00:17
android, hide show elements UI
// listViewItem.setVisibility(View.VISIBLE);
listViewItem.setVisibility(View.INVISIBLE);
//setVisibility(View.GONE) on the Spinners as needed to hide them. GONE means totally gone
@mako34
mako34 / listview example
Created September 17, 2013 01:13
ListView, creacion custom cell, en fragment
1. creo list view en xml
2. lo llamo en el fragment mi list view [inflaiter]
3. adapter custom xml
4. dapter custom CategoryAdapter.java
@mako34
mako34 / xml positioning
Created September 17, 2013 02:05
xml UI elements positioning
//centro vertical
android:gravity="center_vertical"
@mako34
mako34 / editText unfocus on layout
Created September 17, 2013 04:14
android layout dont open editText
myLayout.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
myLayout.setFocusableInTouchMode(true);
@mako34
mako34 / iOS ui element
Created September 17, 2013 04:17
android vs iOS UIElement , comparados
textField
. iOS : UITextField
. android: EditText
@mako34
mako34 / json_array_or_obj
Created September 27, 2013 04:40
Android / Java check a json to know if is an object or array
JSONObject json;
Object intervention;
JSONArray interventionJsonArray;
JSONObject interventionObject;
json = RestManager.getJSONfromURL(myuri); // retrieve the entire json stream
Object intervention = json.get("intervention");
if (intervention instanceof JSONArray) {
// It's an array
interventionJsonArray = (JSONArray)intervention;
@mako34
mako34 / python_simple_chat
Created October 23, 2013 05:28
Python simple chat test, server and client
#server
# TCP Server Code
#host="127.0.0.1" # Set the server address to variable host
host="127.168.2.75" # Set the server address to variable host
port=4446 # Sets the variable port to 4444
from socket import * # Imports socket module
s=socket(AF_INET, SOCK_STREAM)
s.bind((host,port)) # Binds the socket. Note that the input to