class Cliente
{
public int Id {get; set;}
public string Nombre {get; set;}
}
public IEnumerable<Cliente> leerClientesPorAPEPAT(String apepat)
{
var db = new X_XEntities();
var parameter = new SqlParameter("@param", String.Format("%{0}%", apepat));
var c = db.Database.SqlQuery<Cliente>("select top 500 id, nombre from Cliente " +
"where tipper = 1 and " +
"(apepat like @param) ", parameter);
return c;
}
Pure black and white con GIMP
-Colors/Desaturate (removes all color)
- Colors/Threshold (only keeps two levels, adjust threshold to taste)
- Colors/Threshold (only keeps two levels, adjust threshold to taste)
Code First con MVC Data Entity Framework
Web.config
<connectionStrings>
<add name="entity1" connectionString="Data Source=Xdesa;Initial Catalog=cv;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<connectionStrings>
<add name="entity1" connectionString="Data Source=Xdesa;Initial Catalog=cv;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
HomeController.cs
public ActionResult Index()
{
Book libro;
Author a = new Author();
a.AuthorID = 1;
a.FirstName = "nombre2";
a.LastName = "apellido1";
var book = new Book { BookID=1, Author=a, Title="titulo1" };
using (var context = new MyContext())
{
context.Books.Add(book);
context.SaveChanges();
//List<Book> l = context.Books.Where(m => m.BookID > 1).ToList();
libro = context.Books.Where(m => m.BookID > 1).FirstOrDefault();
}
return View(libro);
}
MyContext.cs
public class Book
{
[Key]
public int BookID { get; set; }
public string Title { get; set; }
public Author Author { get; set; }
}
public class Author
{
[Key]
public int AuthorID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public ICollection<Book> Books { get; set; }
}
public class MyContext : DbContext
{
public DbSet<Book> Books { get; set; }
public DbSet<Author> Authors { get; set; }
public MyContext()
: base("name=entity1")
{
}
}
Index.cshtml
<!DOCTYPE html>
@using Curriculums.Models
@model Book
@{
ViewBag.Title = "Index";
}
@Model.BookID - @Model.Title
<h2>Index</h2>
Utilizar fiddler con MVC en localhost
1. http://localhost.fiddler
2. http://nombre-del-pc
3. http://ipv4.fiddler
Si no funciona por problemas de proxy, probar con Chrome en lugar de Internet Explorer
2. http://nombre-del-pc
3. http://ipv4.fiddler
Si no funciona por problemas de proxy, probar con Chrome en lugar de Internet Explorer
Bajar un paquete NuGet sin usar el package explorer
*** Instalar la extensión de Chrome NUTAKE *** Esto agrega un link en cada página del sitio nuget, y se puede bajar haciendo click.
O de otra forma, para hacerlo manual:
https://www.nuget.org/api/v2/package/{packageID}/{packageVersion}
O de otra forma, para hacerlo manual:
https://www.nuget.org/api/v2/package/{packageID}/{packageVersion}
Por ejemplo para bajar este paquete:
Poner esta url:
https://www.nuget.org/api/v2/package/Grid.Mvc/3.1.0-ci1032
Sensores de corriente
Sensores de corriente
Modelo del sensor:
SCT013 (30A/1V)
(www.yhdc.com)
Explicación detallada:
http://openenergymonitor.org/emon/buildingblocks/ct-sensors-interface
Arduino energy monitor:
http://openenergymonitor.org/emon/buildingblocks/how-to-build-an-arduino-energy-monitor-measuring-current-only?page=1
Proyecto con transmisor RF (ver foto de instalación en llave general):
http://labs.stijncoppens.com/thesis/technical/building-a-sensor/
SCT013 (30A/1V)
(www.yhdc.com)
Explicación detallada:
http://openenergymonitor.org/emon/buildingblocks/ct-sensors-interface
Arduino energy monitor:
http://openenergymonitor.org/emon/buildingblocks/how-to-build-an-arduino-energy-monitor-measuring-current-only?page=1
Proyecto con transmisor RF (ver foto de instalación en llave general):
http://labs.stijncoppens.com/thesis/technical/building-a-sensor/
Cambiar la imagen de un ImageView
private Bitmap bm1, bm2;
amarilloOff.setImageResource(R.drawable.amarillo_off);
bm1 = BitmapFactory.decodeResource(getResources(), R.drawable.amarillo_on);
bm2 = BitmapFactory.decodeResource(getResources(), R.drawable.amarillo_off);
amarilloOff.setImageBitmap(bm1);
amarilloOff.setImageResource(R.drawable.amarillo_off);
bm1 = BitmapFactory.decodeResource(getResources(), R.drawable.amarillo_on);
bm2 = BitmapFactory.decodeResource(getResources(), R.drawable.amarillo_off);
amarilloOff.setImageBitmap(bm1);
Configurar Admob con Google Play Services en Android
1. Agregar en build.gradle la linea 'com.google.android.gms...'
apply plugin: 'android'
...
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:5.0.77'
}
IR A TOOLS / ANDROID / SYNC PROJECT WITH GRADLE FILES y esperar a que las referencias queden bien (no queden en rojo)
2. Agregar un import en el .java
import com.google.android.gms.ads.*;
3. Agregar en AndroidManifest.xml (dentro del tag <application>)
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
4. Antes del tag <application> agregar:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
5. Usar este codigo en el MyActivity.java
package com.expressraider.admob;
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import com.google.android.gms.ads.*;
public class MyActivity extends Activity {
private AdView mAdView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_principal);
//------------- ADS --------------------------//
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
// Create a banner ad. The ad size and ad unit ID must be set before calling loadAd.
mAdView = new AdView(this);
mAdView.setAdSize(AdSize.SMART_BANNER);
mAdView.setAdUnitId("ca-app-pub-0665940275249022/9155234413");
mAdView.setLayoutParams(new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT,
Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM));
TelephonyManager teleManager =(TelephonyManager)getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
String device_id=teleManager.getDeviceId();
//obtengo el id del telefono, para agregarlo como dispositivo de testing
String android_id = Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
AdRequest adRequest=new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice(deviceId).build();
FrameLayout.LayoutParams initialFrm = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT,
Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
this.addContentView(mAdView, initialFrm);
mAdView.loadAd(adRequest);
}
@Override
public void onResume() {
super.onResume();
// Resume the AdView.
mAdView.resume();
}
@Override
public void onPause() {
// Pause the AdView.
mAdView.pause();
super.onPause();
}
@Override
public void onDestroy() {
// Destroy the AdView.
mAdView.destroy();
super.onDestroy();
}
}
6. Si da error cuando se ejecuta, ver en el LogCat esta linea:
7. En mAdView.setAdUnitId hay que poner el pub ID, que se obtiene de admob de esta forma:
ir a admob
ir a ficha Monetizar
ver en los bloques de anuncios, que dice ca-app-pub-0665940275249022/9155234413
ese es el que hay que poner.
ca-app-pub-0665940275249022/9155234413
apply plugin: 'android'
...
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:5.0.77'
}
IR A TOOLS / ANDROID / SYNC PROJECT WITH GRADLE FILES y esperar a que las referencias queden bien (no queden en rojo)
2. Agregar un import en el .java
import com.google.android.gms.ads.*;
3. Agregar en AndroidManifest.xml (dentro del tag <application>)
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
4. Antes del tag <application> agregar:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
5. Usar este codigo en el MyActivity.java
package com.expressraider.admob;
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import com.google.android.gms.ads.*;
public class MyActivity extends Activity {
private AdView mAdView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_principal);
//------------- ADS --------------------------//
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
// Create a banner ad. The ad size and ad unit ID must be set before calling loadAd.
mAdView = new AdView(this);
mAdView.setAdSize(AdSize.SMART_BANNER);
mAdView.setAdUnitId("ca-app-pub-0665940275249022/9155234413");
mAdView.setLayoutParams(new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT,
Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM));
TelephonyManager teleManager =(TelephonyManager)getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
String device_id=teleManager.getDeviceId();
//obtengo el id del telefono, para agregarlo como dispositivo de testing
String android_id = Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
AdRequest adRequest=new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice(deviceId).build();
FrameLayout.LayoutParams initialFrm = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT,
Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
this.addContentView(mAdView, initialFrm);
mAdView.loadAd(adRequest);
}
public void onResume() {
super.onResume();
// Resume the AdView.
mAdView.resume();
}
@Override
public void onPause() {
// Pause the AdView.
mAdView.pause();
super.onPause();
}
@Override
public void onDestroy() {
// Destroy the AdView.
mAdView.destroy();
super.onDestroy();
}
}
6. Si da error cuando se ejecuta, ver en el LogCat esta linea:
7. En mAdView.setAdUnitId hay que poner el pub ID, que se obtiene de admob de esta forma:
ir a admob
ir a ficha Monetizar
ver en los bloques de anuncios, que dice ca-app-pub-0665940275249022/9155234413
ese es el que hay que poner.
ca-app-pub-0665940275249022/9155234413
Cannot resolve symbol Activity
Si aparecen errores de "Cannot resolve symbol..."
Verificar en app/build.gradle que las versiones se correspondan
por ej.
MAL:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.expressraider.prueba1"
minSdkVersion 11
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
Verificar en app/build.gradle que las versiones se correspondan
por ej.
MAL:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.expressraider.prueba1"
minSdkVersion 11
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
BIEN
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.expressraider.prueba1"
minSdkVersion 11
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
Cambiar la version de compilacion y el target SDK
1. Ir a File / Project Structure
2. En la ficha Flavors, esta la min sdk version y la target sdk version
2. En la ficha Flavors, esta la min sdk version y la target sdk version
Mantener seleccionado un item del ListView
public class MantMatriculas extends Activity {
private ListView lstMatriculas;
private View lastSelectedView = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mant_matriculas);
lstMatriculas = (ListView)findViewById(R.id.lstMatriculas);
ArrayList<String> values =
new ArrayList<String>();
values.add("matricula1");
values.add("matricula2");
values.add("matricula3");
values.add("matricula4");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, values);
lstMatriculas.setAdapter(adapter);
lstMatriculas.setItemsCanFocus(false);
lstMatriculas.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
lstMatriculas.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parentAdapter, View view, int position,
long id) {
if (lastSelectedView != null)
{
lastSelectedView.setBackgroundColor(Color.TRANSPARENT);
}
lastSelectedView = view;
view.setBackgroundColor(Color.CYAN);
}
});
}
private ListView lstMatriculas;
private View lastSelectedView = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mant_matriculas);
lstMatriculas = (ListView)findViewById(R.id.lstMatriculas);
ArrayList<String> values =
new ArrayList<String>();
values.add("matricula1");
values.add("matricula2");
values.add("matricula3");
values.add("matricula4");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, values);
lstMatriculas.setAdapter(adapter);
lstMatriculas.setItemsCanFocus(false);
lstMatriculas.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
lstMatriculas.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parentAdapter, View view, int position,
long id) {
if (lastSelectedView != null)
{
lastSelectedView.setBackgroundColor(Color.TRANSPARENT);
}
lastSelectedView = view;
view.setBackgroundColor(Color.CYAN);
}
});
}
}
Centrar texto en TextView
1. Agregar un linear layout (horizontal)
2. Agregar un TextView dentro del linear layout
3. Setear la propiedad gravity del linear layout en Center (la gravity no la layout:gravity)
2. Agregar un TextView dentro del linear layout
3. Setear la propiedad gravity del linear layout en Center (la gravity no la layout:gravity)
Suscribirse a:
Entradas (Atom)
