Mostrar Mensajes

Esta sección te permite ver todos los posts escritos por este usuario. Ten en cuenta que sólo puedes ver los posts escritos en zonas a las que tienes acceso en este momento.


Mensajes - Tino

Páginas: [1] 2
1
Hola
He realizado una aplicacion relacionada con mi trabajo. Practicamente esta terminada, pero ahora quiero que mande una notificacion un dia antes del dia que comienzo a trabajar. La forma de realizar notificaciones si entiendo como se hace, pero si la aplicacion no sta abierta tendria que estar sincronizada con el calendario de android (los dias de trabajo) o no. Aclararmelo por favor.
Como siempre muchas gracias por la atencion
Un saludo.

2
Hola Alex, muchisimas gracias por tu tiempo y dedicacion.
Si te das cuenta el codigo que me has sugerido es el mismo que yo he realizado . Pero al tratar de compartir (y estoy utilizando de emulador el movil) solo me sale gmail, drive, email y la propia aplicacion. No el whatsApp Creo que el filtro que he introducido en el Manifest esta bien. No se donde buscar solucion.
Gracias de nuevo. Un saludo

3
Hola. Trato de compartir informacion de una aplicacion a traves de Action Send. Solamente me da opcion de hacerlo a traves de correo electronico. Me gustaria que me diese opcion con whatsApp. El código es el siguiente:

Código: [Seleccionar]
case R.id.menu_contextual_compartir:
        editarPersona((int)info.id);
        String comp = extras.getString("dcompañero");
      String diaS =extras.getString("dseleccionado");
          String diaC = extras.getString("dcambio");
        String texto = "Hola "+comp+ " el cambio está hecho, tu me haces el "
        +diaS+ ", te lo devuelvo el "+diaC+". Un saludo." ;
        Intent sendIntent= new Intent();
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_TEXT, texto);
        sendIntent.setType("Text/plain");
        startActivity(sendIntent);


En el manifest he colocado esto en la actyvity

Código: [Seleccionar]
<activity
            android:name="com.proyectosTino.mcalendar.ListaCambios"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="Text/plain"/>
            </intent-filter>
        </activity>
.

He probado la aplicacion en el movil y nada.

Por favor volverme a orientar. gracias

4
Aprender a programar desde cero / Re:Problema con ciclos
« en: 05 de Noviembre 2015, 17:17 »
Gracias por la ayuda, de nuevo. He resuelto el problema utilizando "contains" en vez de "equals". Queda asi:
Código: [Seleccionar]
public boolean permisos(String string){
       DataBaseCambios bd= null;
        bd = new DataBaseCambios(_context);
      String[] separatedTime;
       String   diaPermiso="";
         diaPermiso = bd.diasPrmisos();
         separatedTime = diaPermiso.split(",");
        int numero = separatedTime.length;
        List<String>l=Arrays.asList(diaPermiso.split(","));
return l.contains(string);
       
       }
Gracias de nuevo

5
Hola. tengo un problema . Trato de con los dias de cada mes y que coincidan con los que yo he guardado en una base de datos cambiarles de aspecto en un calendario: para ello la variable "dias es un lists de los dias del mes.

y" separateTime" es an array con los dias guardados en la base de datos"bd, En la actualidad los dias guardados ,son (29,26,27,31, del 7-2015, 16-8-2015 y 13-9-2015).

Para ello creo un metodo" permisos" donde en teoria calcula las coincidencias que le paso del primer metodo "diasde trabajo" que le pasa los dias del mes.

Lo que ocurre es que solo cambia el ultimo dia 13-9.

No se como arregrarlo.

Los metodos son:

Código: [Seleccionar]
public List<String> diasdeTrabajo(){
LocalDate hoy = LocalDate.now();
LocalDate inicio = LocalDate.parse("2014-02-01");
  boolean permiso;
   for (int i = 0; i < dias.size(); i++) {
  String dia1 = dias.get(i);
  permiso= permisos(dia1);
  if(permiso==true){
list.add(dias.get(i) + "-CAMBIO");

  }else{
String[] dateArr = dias.get(i).split("-"); 
String diaa = dateArr[0];
String mes = dateArr[1];
String año = dateArr[2];
int mess = Integer.parseInt(dateArr[1]) + 1;
String messs = String.valueOf(mess);
String diac = diaa + "-" + messs + "-" + año;

DateTimeFormatter dtf = DateTimeFormat.forPattern("dd-MM-yyyy");
LocalDate diasdeTrabajo = LocalDate.parse(diac, dtf);
Days dia = Days.daysBetween(inicio, diasdeTrabajo);
int days = dia.getDays();
int seg2 = days % 8;
     if(seg2 == 1 || seg2 == 3) {
list.add(dias.get(i) + "-CURRO");
    }else if (seg2 == 4){
list.add(dias.get(i) + "-CURRON");
    }
 
    else  {
list.add(dias.get(i) + "-WHITE");
    }
     
   }
   }
return list;
}
y
Código: [Seleccionar]
public boolean permisos(String string){
         boolean permiso = false;
        DataBaseCambios bd= null;
        bd = new DataBaseCambios(_context);
      String[] separatedTime;
       String   diaPermiso="";
       diaPermiso = bd.diasPrmisos();
         separatedTime = diaPermiso.split(",");
        int numero = separatedTime.length;
        Vector<String> vector = new Vector<String>();
        for (int i = 0; i<numero;i++){
        vector.add(separatedTime[i]);
        }
    ArrayList<String> al = new ArrayList<String>(vector);
   
    for(int i =0; i<numero;i++){
   
    if( string.equals(separatedTime[i])){
   
    permiso= true;
    }else{
    permiso = false;
    }
    }
return permiso;

    }
Gracias

6
Hola Alex.
Creí que nunca lo iba a poder decir, pero este tema lo hemos solucionado. Han pasado muchos dias pero no lo puedo dedicar mucho tiempo a la semana. Ademas de mi torpeza.....
Bien al parecer eclipse o android no trabaja con java 8. Con lo cual no podia emular el proyecto, me daba unos errores indescriptibles...Alguien me aconsejo que utilizara esta libreria;http://www.joda.org/joda-time/. Asi lo hice y despues de no pocos problemas (el eclipse lo estoy cogiendo panico) todo salió. El metodo dichoso queda asi:
Código: [Seleccionar]
public List<String> diasdeTrabajo() {
       
LocalDate hoy =LocalDate.now();
LocalDate inicio = LocalDate.parse("2014-02-01");

for (int i = 0; i < dias.size(); i++) {
String[] dateArr =  dias.get(i).split("-"); // date format is yyyy-mm-dd
String diaa = dateArr[0];
String mes =  dateArr[1] ;
    String año = dateArr[2];
int mess=    Integer.parseInt(dateArr[1])+1;
String messs = String.valueOf(mess);
String diac = diaa+"-"+ messs +"-"+año;



DateTimeFormatter dtf = DateTimeFormat.forPattern("dd-MM-yyyy");
            LocalDate diasdeTrabajo =LocalDate.parse(diac, dtf);
            Days dia = Days.daysBetween(inicio, diasdeTrabajo);
            int days = dia.getDays();
   

int seg2 = days % 8;
if (seg2 == 1 || seg2 == 3 || seg2 == 4) {
list.add(dias.get(i) + "-CURRO");

} else {
list.add(dias.get(i) + "-WHITE");

}
}
return dias;

}
Hay lineas de codigo en el ciclo for que las tengo que utilizar porque me daba problemas con los meses despues de novienbre(tamaño de un array).
Gracias a gente como vosotros, principiantes como yo pueden tener satisfaciones como la que tuve el otro dia cuando por fin me salio el calendario. Muchas gracias por el tiempo que me has dedicado. Yo seguire con mi proyecto,pero con la seguridad que me da el saber que no estoy solo.
Lo dicho, gracias por existir y hasta la proxima.

7
Hola de nuevo, creo que lo voy solucionando. Ya consigo que los import aparezca java.time.
He hecho esto:i solved this problem by trying following solution

Project > Properties > Java Build Path
Select Libraries tab
Select JRE System Library
Click Edit button
Choose an alternate JRE (jre1.8.0_20)
Click Finish button

Si alguien lo necesita que me lo diga ,porque soy muy necio y no tengo muy claro lo que he hecho configurando el eclipse.
Gracias de nuevo y reportare el resultado si es ok???? que lo pongo en duda; habra mas problemas.

8
Perdon. La variable i la doy un valor de 10 porque con 1 me da error.
Tambien los meses que tienen 30 dias. Pero para comprobar los errores anteriores es suficiente.
Código: [Seleccionar]
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.Month;
import java.time.Period;
import java.time.temporal.ChronoUnit;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;


public class Calendario {

/**
* @param args
* @throws ParseException
*/
public static void main(String[] args) throws ParseException {
// TODO Auto-generated method stub

   dameCalendario("2015-01-");
        //dameCalendario("2015-02-");
        dameCalendario("2015-03-");
      //  dameCalendario("2015-04-");
        dameCalendario("2015-05-");
        dameCalendario("2015-07-");
       
}
       
        public static void dameCalendario(String mesYaño) throws ParseException {

   
   
  LocalDate hoy = LocalDate.now();
  LocalDate inicio = LocalDate.of(2014, Month.FEBRUARY,1);
  LocalDate inicio2 = LocalDate.parse("2014-02-01");
  //Period dif = Period.between(hoy, inicio);
  long dif = ChronoUnit.DAYS.between(inicio,hoy);
 
 
    for (int i=10; i<=31;i++) {
         
String dias =mesYaño+i;

   
             LocalDate diatrabajo = LocalDate.parse(dias);
   
         
             
            long dia = ChronoUnit.DAYS.between(inicio,diatrabajo);
           
              System.out.print(" Ahora dia vale: "+dia);
              int seg2 = (int) (dia % 8);
              System.out.print(" El resto de dia entre 8 es: "+ seg2 + "   .    ");
              if(seg2 ==1 || seg2 == 3|| seg2== 4){
                  System.out.println("T-Trabajo el:"+ diatrabajo );
              }else{ 
                  System.out.println("L-Libre el dia:"+ diatrabajo );
              }
          }
}
       
}
Gracias

9
Hola. Lo primero muchisimas gracias porque utilizando java 8 con java.time. el problema aparentemente desaparece.
Bien pero ahora quieroutilizarlo en android, en el proyecto que tengo y no exixte la Clse ni los import. Cimo puedo solucionar esto? Tengo que empezar de cero?. Me he descargado el eclipse luna que mirando si acepta java8 pero importo el proyecto y tampoco nada.
Y ahora que?
Muchisimas gracias de nuevo.

10
Hola.
Utilizo los digitos 1,3,4 porque me da valido ciertos meses.
Al correr el metodo que me ha pasado me sige dando los mismos problemas:"Cuando introduzco el "29-03-2015" me da 452 y trabajo. Pero al meter "30-03-2015" me da tambien 452 y obviamente trabajo.Luego hice la prueba de 28 de febrero es decir "28-01-2015" me da 392 y no trabajo.Meto el dia siguiente 01-02-2015 y me da 396 y trabajo. Es decir que el "01" no es febrero sino un mes de 31 dias porque cuenta el 29,30,31.
Luego el 31-02-2015   me da 426 y el 01-03-2015  me da 424 dos dias menos."

En la aplicacion he creado un TexView debajo del calendario. Le voy a pasar un archivo donde aparece la variable "dias" que es la entrada en formato de los dias del mes:
 Es el primer archivo adjunto."febrero". Luego le paso otro con la salida del metodo con los dias de trabajo y no trabajo. Y vera el mes de marzo como la cadencia desaparece, en circulo rojo estan lo que tendria que ser.
Cada vez entiendo menos. Por donde puedo seguir.
Gracias.
No me deja adjuntar: Le dejo un enlace para visualizarlo:
 https://www.dropbox.com/s/wmusvg8mm3k93li/dias.png?dl=0
https://www.dropbox.com/s/xuho254nl9q8vmq/feb-marzo.jpg?dl=0,

11
Hola de nuevo. He intentado seguir el hilo pero he debido crear otro.... un desastre.
He creado un proyecto en java con solamente el metodo donde calculo los dias de trabajo, que es el que me esta dando los errores. El codigo es:
 
Código: [Seleccionar]
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
import java.util.Calendar;
import java.util.Date;

public class Calendario {

/**
* @param args
* @throws ParseException
*/
public static void main(String[] args) throws ParseException {
// TODO Auto-generated method stub
SimpleDateFormat formato = new SimpleDateFormat("dd-MM-yyyy");
  GregorianCalendar cal = new GregorianCalendar();
   
  int año = 2014;
  int mes = 00;
  int diaa = 01; // 
  Calendar calendar = new GregorianCalendar(año,mes,diaa);
  long fecha = calendar.getTimeInMillis();
  String dias = "01-03-2015";
         Date date = null;
  date = formato.parse(dias );
  cal.setTime(date);
    long dia = cal.getTimeInMillis();
  dia =dia-fecha;
  dia=dia/(1000*60*60*24);
  int seg2 = (int) (dia % 8);
      if(seg2 ==1 || seg2 == 3|| seg2== 4){
  System.out.print("Trabajo el:"+ dia);
      }else{ 
    System.out.print("No trabajo el dia:"+ dia);
  }
}
}
Las variables año, mes y diaa son el inicio del calculo: 1 de enero de 2014
En el String dia voy introduciendo fechas a ver que resultado me da.
Te comentaba que me daba buenos resultados un mes si y otro no....
Y me aparecen cosas muy estrañas:
Cuando introduzco el "29-03-2015" me da 452 y trabajo. Pero al meter "30-03-2015" me da tambien 452 y obviamente trabajo.

Luego hice la prueba de 28 de febrero es decir "28-01-2015" me da 392 y no trabajo.

Meto el dia siguiente 01-02-2015 y me da 396 y trabajo. Es decir que el "01" no es febrero sino un mes de 31 dias porque cuenta el 29,30,31.

Luego el 31-02-2015   me da 426 y el 01-03-2015  me da 424 dos dias menos.
A que se debe esto?  Me falta codigo?. Como puedo arregrarlo?
Gracias de nuevo.

12
Aprender a programar desde cero / Re:Problema fechas
« en: 02 de Marzo 2015, 21:26 »
Hola. Han pasado muchos dias y he estado fuera , voy a tratar de retomar el proyecto.
He investigado por mi cuenta y el metodo donde calculo los dias de trabajo da errores.
He creado un proyecto den java con solo el metodo:
Código: [Seleccionar]
public class Calendario {

/**
* @param args
* @throws ParseException
*/
public static void main(String[] args) throws ParseException {
// TODO Auto-generated method stub
SimpleDateFormat formato = new SimpleDateFormat("dd-MM-yyyy");
  GregorianCalendar cal = new GregorianCalendar();
   
  int año = 2014;
  int mes = 00;
  int diaa = 01; // 
  Calendar calendar = new GregorianCalendar(año,mes,diaa);
  long fecha = calendar.getTimeInMillis();
  String dias = "01-03-2015";
         Date date = null;
  date = formato.parse(dias );
  cal.setTime(date);
    long dia = cal.getTimeInMillis();
  dia =dia-fecha;
  dia=dia/(1000*60*60*24);
  int seg2 = (int) (dia % 8);
      if(seg2 ==1 || seg2 == 3|| seg2== 4){
  System.out.print("Trabajo el:"+ dia);
      }else{ 
    System.out.print("No trabajo el dia:"+ dia);
  }
}
}
Las variables año, mes y diaa son el inicio del calculo: 1 de enero de 2014
En el String dia voy introduciendo fechas a ver que resultado me da.
Te comentaba que me daba buenos resultados un mes si y otro no....
Y me aparecen cosas muy estrañas:
Cuando introduzco el "29-03-2015" me da 452 y trabajo. Pero al meter "30-03-2015" me da tambien 452 y obviamente trabajo.

Luego hice la prueba de 28 de febrero es decir "28-01-2015" me da 392 y no trabajo.

Meto el dia siguiente 01-02-2015 y me da 396 y trabajo. Es decir que el "01" no es febrero sino un mes de 31 dias porque cuenta el 29,30,31.

Luego el 31-02-2015   me da 426 y el 01-03-2015  me da 424 dos dias menos.
A que se debe esto?  Me falta codigo?. Como puedo arregrarlo?
Gracias de nuevo.

13
Aprender a programar desde cero / Re:Problema fechas
« en: 18 de Enero 2015, 00:58 »
Hola Ogramar.
Feliz año. No he podido contestar antes. Disculpa si no quedo claro que era un proyecto android. Lo estoy haciendo con eclipse, lo que dices de codigo de test no se como se hace. Tampoco se donde me pueden ayudar para android. Si tu conoces algun sitio te lo agradeceria. De todas formas gracias por el tiempo que me has dedicado.
Un saludo

14
Aprender a programar desde cero / Re:Problema fechas
« en: 21 de Diciembre 2014, 00:58 »
Hola.
Intentare poner para compartii un enlace del proyecto, yo lo estoy haciendo con eclipse.
Intentare subir tambien la apk para poder instalar en movil.
https://www.dropbox.com/s/5s7qur50duwaupm/MyCalendarActivity.zip?dl=0  este esel proyecto
https://www.dropbox.com/s/rb47otxajj0ioqp/MyCalendarActivity.apk?dl=0 y este es la apk-
Espero que pueda servir. Gracias

15
Aprender a programar desde cero / Re:Problema fechas
« en: 20 de Diciembre 2014, 15:52 »
Hola. Muchas gracias por dedicarme tu tiempo. El problema es que el método esta incluido  en un proyecto de calendario. Es decir el fallo se ve en la vista del calendario.  O puedo adjuntar el archivo por que es mayor de 179 kb. Hay alguna forma poderte llegar el archivo?. Con el verías el fallo que te digo. Porque lo que me desorienta es que el cálculo esta bien hecho pero en esos meses se me  adelanta un día. Es como si la vista y los cálculos tuvieran mala sincronizados.  Hubiera un mes de diferencia.  A que puede ser debido? Por favor como puedo haceros llegar el archivo.?
Gracias.

16
Aprender a programar desde cero / Problema fechas
« en: 18 de Diciembre 2014, 23:09 »
Hola.
Tengo un problema con un metodo que he realzado sobre calculo de diferencias de fechas. Todo va bien pero a la hora de visualizar el resultado este es optimo unos meses y otros no: Enero ,febrero, abril,junio, agosto , setiembre y noviembre me da correcto pero el resto: marzo se me atrasa dos dias el resutado, mayo, julio,octubre y diciembre lo hace un dia. No se donde puede estar el problema-.
El metodo es el siguiente:
Código: [Seleccionar]
public List<String>  diasdeTrabajo(){
   
int GUARDIACUATRO1 =16071;
SimpleDateFormat formato = new SimpleDateFormat("dd-MM-yyyy", new Locale("es_ES"));
Calendar cal = GregorianCalendar.getInstance();
      Date date = null;

  for (int i=0; i< dias.size() ; i++){
try {
date = formato.parse(dias.get(i));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
cal.setTime(date);
Long dia= cal.getTimeInMillis();
dia = dia/(1000*60*60*24);
dia =dia-GUARDIACUATRO1 ;
int seg2 = (int) (dia % 8);
    if(seg2 ==1 || seg2 == 3|| seg2== 4){
list.add(dias.get(i)+"-CURRO");
    }else{ 
   list.add(dias.get(i)+"-WHITE");
}
}
    return list;
                    }
 
la variable dias es un arrayList con los dias del mes en formato dd-MM-yy.
La constante son los dias que hay hasta el 1-1-2014
y el return es otro arrayList con los dias que curro en el mes.
Ayuda

17
No me deja mandar el archio rar del proyecto. Se lo puedo mandar donde me digan.

18
Hola de nuevo.
He dedicado algo de tiempo , y al final he conseguido casi lo que quiero. Recordando trato de hacer un calendario de trabajo. He creado un metodo que le paso un arraylist con los dias del mes en formato "dd-mm-yy" lo he llamado dias.

Código: [Seleccionar]
public List<String>  diasdeTrabajo(){
   
int GUARDIACUATRO1 =16071;
SimpleDateFormat formato = new SimpleDateFormat("dd-MM-yyyy");
Calendar cal = GregorianCalendar.getInstance();
Date date = null;

  for (int i=0; i< dias.size() ; i++){
try {
date = formato.parse(dias.get(i));

} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
cal.setTime(date);
Long dia= cal.getTimeInMillis();
dia = dia/(1000*60*60*24);
dia =dia-GUARDIACUATRO1 ;
int seg2 = (int) (dia % 8);

if(seg2 == 1 || seg2 == 3|| seg2== 4){

list.add(dias.get(i)+"-CURRO");
}else{ 
list.add(dias.get(i)+"-WHITE");
      }
}

  return list;

Debajo del calendario puse un TextView donde me aparece los "dias" de mes. que siempre son correctos.
El retorno es otro arrayList "list" que es el que se utilza para crearla vista de trabajo.
Bien pues el inicio de mi proyecto es el 1 de febrero del 2014. Febrero bien(los dias de trabajo en rojo), marzo mal se me adelanta en un dia...... Asi todos los meses.....abril bien, mayo mal,junio bien, julio mal.....No encuentro el porque.
Por favor estoy ya desesperado. Ayuda por favor. No me deja adjuntar un rar Os coloco todo el codigo.

 
Código: [Seleccionar]
package com.examples;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

@TargetApi(3)
public class MyCalendarActivity extends Activity implements OnClickListener {
private static final String tag = "MyCalendarActivity";

private TextView currentMonth;
private Button selectedDayMonthYearButton;
private ImageView prevMonth;
private ImageView nextMonth;
private GridView calendarView;
private GridCellAdapter adapter;
private Calendar _calendar;
@SuppressLint("NewApi")
private int month, year;
@SuppressWarnings("unused")
@SuppressLint({ "NewApi", "NewApi", "NewApi", "NewApi" })
private final SimpleDateFormat dateFormatter = new SimpleDateFormat("dd-MM-yy");
private static final String dateTemplate = "MMMM yyyy";



private TextView textoprueba;
    long seg ;
  //  ArrayList<String> prueba = new ArrayList<String>();

private String trabajo;
   
 
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_calendar_view);

_calendar = Calendar.getInstance(Locale.getDefault());
month = _calendar.get(Calendar.MONTH) + 1;
year = _calendar.get(Calendar.YEAR);
Log.d(tag, "Calendar Instance:= " + "Month: " + month + " " + "Year: "
+ year);

selectedDayMonthYearButton = (Button) this
.findViewById(R.id.selectedDayMonthYear);
selectedDayMonthYearButton.setText("Selected: ");

prevMonth = (ImageView) this.findViewById(R.id.prevMonth);
prevMonth.setOnClickListener(this);

currentMonth = (TextView) this.findViewById(R.id.currentMonth);
currentMonth.setText(DateFormat.format(dateTemplate,
_calendar.getTime()));
         
nextMonth = (ImageView) this.findViewById(R.id.nextMonth);
nextMonth.setOnClickListener(this);

calendarView = (GridView) this.findViewById(R.id.calendar);

// Initialised
adapter = new GridCellAdapter(getApplicationContext(),
R.id.calendar_day_gridcell, month, year);
adapter.notifyDataSetChanged();
calendarView.setAdapter(adapter);


textoprueba = (TextView)this.findViewById(R.id.textoPruebas);



}
 



/**
*
* @param month
* @param year
*/
private void setGridCellAdapterToDate(int month, int year) {
adapter = new GridCellAdapter(getApplicationContext(),
R.id.calendar_day_gridcell, month, year);
_calendar.set(year, month - 1, _calendar.get(Calendar.DAY_OF_MONTH));
currentMonth.setText(DateFormat.format(dateTemplate,
_calendar.getTime()));
adapter.notifyDataSetChanged();
calendarView.setAdapter(adapter);
}

@Override
public void onClick(View v) {
if (v == prevMonth) {
if (month <= 1) {
month = 12;
year--;
} else {
month--;
}
Log.d(tag, "Setting Prev Month in GridCellAdapter: " + "Month: "
+ month + " Year: " + year);
setGridCellAdapterToDate(month, year);
}
if (v == nextMonth) {
if (month > 11) {
month = 1;
year++;
} else {
month++;
}
Log.d(tag, "Setting Next Month in GridCellAdapter: " + "Month: "
+ month + " Year: " + year);
setGridCellAdapterToDate(month, year);
}

}

@Override
public void onDestroy() {
Log.d(tag, "Destroying View ...");
super.onDestroy();
}

// Inner Class
public class GridCellAdapter extends BaseAdapter implements OnClickListener {
private static final String tag = "GridCellAdapter";
private final Context _context;

private   List<String> list;
private static final int DAY_OFFSET = 1;
private final String[] weekdays = new String[] { "Sun", "Mon", "Tue",
"Wed", "Thu", "Fri", "Sat" };
//private final String[] months = { "January", "February", "March",
// "April", "May", "June", "July", "August", "September",
// "October", "November", "December" };
private final String[] months ={"00","01","02","03","04","05","06","07","08","09","10","11"};
private final int[] daysOfMonth = { 31, 28, 31, 30, 31, 30, 31, 31, 30,
31, 30, 31 };
private int daysInMonth;
private int currentDayOfMonth;
private int currentWeekDay;
private Button gridcell;
private TextView num_events_per_day;
private final HashMap<String, Integer> eventsPerMonthMap;
private final SimpleDateFormat dateFormatter = new SimpleDateFormat(
"dd-MM-yy"); //"dd-MMM-yyyy"


private   List<String>dias;
private   List<String>diaTrabajo;
   
String[] day_color ;
String theday  ;
String themonth ;
String theyear;

String[]dias_curro;
String dcurro;
String mcurro;
String acurro;


 
// Days in Current Month
public GridCellAdapter(Context context, int textViewResourceId,
int month, int year) {
super();
this._context = context;
this.list = new ArrayList<String>();
Log.d(tag, "==> Passed in Date FOR Month: " + month + " "
+ "Year: " + year);
Calendar calendar = Calendar.getInstance();
setCurrentDayOfMonth(calendar.get(Calendar.DAY_OF_MONTH));
setCurrentWeekDay(calendar.get(Calendar.DAY_OF_WEEK));
Log.d(tag, "New Calendar:= " + calendar.getTime().toString());
Log.d(tag, "CurrentDayOfWeek :" + getCurrentWeekDay());
Log.d(tag, "CurrentDayOfMonth :" + getCurrentDayOfMonth());

this.dias = new ArrayList<String>();
this.diaTrabajo= new ArrayList<String>();
   
// Print Month
printMonth(month, year);

// Find Number of Events
eventsPerMonthMap = findNumberOfEventsPerMonth(year, month);

// diasdeTrabajo();

 

}

private String getMonthAsString(int i) {
return months[i];
}

private String getWeekDayAsString(int i) {
return weekdays[i];
}

private int getNumberOfDaysOfMonth(int i) {
return daysOfMonth[i];
}

public String getItem(int position) {
return list.get(position);
}

@Override
public int getCount() {
return list.size();
}

/**
* Prints Month
*
* @param mm
* @param yy
*/
private void printMonth(int mm, int yy) {
Log.d(tag, "==> printMonth: mm: " + mm + " " + "yy: " + yy);
int trailingSpaces = 0;
int daysInPrevMonth = 0;
int prevMonth = 0;
int prevYear = 0;
int nextMonth = 0;
int nextYear = 0;

int currentMonth = mm - 1;
String currentMonthName = getMonthAsString(currentMonth);
daysInMonth = getNumberOfDaysOfMonth(currentMonth);

Log.d(tag, "Current Month: " + " " + currentMonthName + " having "
+ daysInMonth + " days.");

GregorianCalendar cal = new GregorianCalendar(yy, currentMonth, 0);
Log.d(tag, "Gregorian Calendar:= " + cal.getTime().toString());

if (currentMonth == 11) {
prevMonth = currentMonth - 1;
daysInPrevMonth = getNumberOfDaysOfMonth(prevMonth);
nextMonth = 0;
prevYear = yy;
nextYear = yy + 1;
Log.d(tag, "*->PrevYear: " + prevYear + " PrevMonth:"
+ prevMonth + " NextMonth: " + nextMonth
+ " NextYear: " + nextYear);
} else if (currentMonth == 0) {
prevMonth = 11;
prevYear = yy - 1;
nextYear = yy;
daysInPrevMonth = getNumberOfDaysOfMonth(prevMonth);
nextMonth = 1;
Log.d(tag, "**--> PrevYear: " + prevYear + " PrevMonth:"
+ prevMonth + " NextMonth: " + nextMonth
+ " NextYear: " + nextYear);
} else {
prevMonth = currentMonth - 1;
nextMonth = currentMonth + 1;
nextYear = yy;
prevYear = yy;
daysInPrevMonth = getNumberOfDaysOfMonth(prevMonth);
Log.d(tag, "***---> PrevYear: " + prevYear + " PrevMonth:"
+ prevMonth + " NextMonth: " + nextMonth
+ " NextYear: " + nextYear);
}

int currentWeekDay = cal.get(Calendar.DAY_OF_WEEK) - 1;
trailingSpaces = currentWeekDay;

Log.d(tag, "Week Day:" + currentWeekDay + " is "
+ getWeekDayAsString(currentWeekDay));
Log.d(tag, "No. Trailing space to Add: " + trailingSpaces);
Log.d(tag, "No. of Days in Previous Month: " + daysInPrevMonth);

if (cal.isLeapYear(cal.get(Calendar.YEAR)))
if (mm == 2)
++daysInMonth;
else if (mm == 3)
++daysInPrevMonth;

// Trailing Month days
for (int i = 0; i < trailingSpaces; i++) {
Log.d(tag,
"PREV MONTH:= "
+ prevMonth
+ " => "
+ getMonthAsString(prevMonth)
+ " "
+ String.valueOf((daysInPrevMonth
- trailingSpaces + DAY_OFFSET)
+ i));
list.add(String
.valueOf((daysInPrevMonth - trailingSpaces + DAY_OFFSET)
+ i)+ "-"
+ getMonthAsString(prevMonth)
+ "-"
+ prevYear+ "-GREY" );//+ "-GREY"
}

// Current Month Days
for (int i =1; i <= daysInMonth; i++) {
Log.d(currentMonthName, String.valueOf(i) + " "
+ getMonthAsString(currentMonth) + " " + yy);
     dias.add(String.valueOf(i)+"-"+getMonthAsString(currentMonth)+ "-"+yy );
     

}
if(getMonthAsString(currentMonth) !=null){
   diasdeTrabajo();

}
 
/*        if (i == getCurrentDayOfMonth()) {
list.add(String.valueOf(i)  + "-"+ getMonthAsString(currentMonth) + "-" + yy+"-BLUE");//
   }  else {
list.add(String.valueOf(i)  + "-"+ getMonthAsString(currentMonth) + "-" + yy+"-WHITE" );//+"-WHITE"
}*/
 
     
     


// Leading Month days
for (int i = 0; i < list.size() % 7; i++) {
Log.d(tag, "NEXT MONTH:= " + getMonthAsString(nextMonth));
list.add(String.valueOf(i + 1) + "-"
+ getMonthAsString(nextMonth) + "-" + nextYear+"-GREY"  );//+"-GREY"
}

}

/**
* NOTE: YOU NEED TO IMPLEMENT THIS PART Given the YEAR, MONTH, retrieve
* ALL entries from a SQLite database for that month. Iterate over the
* List of All entries, and get the dateCreated, which is converted into
* day.
*
* @param year
* @param month
* @return
*/
private HashMap<String, Integer> findNumberOfEventsPerMonth(int year,
int month) {
HashMap<String, Integer> map = new HashMap<String, Integer>();

return map;
}

@Override
public long getItemId(int position) {
return position;
}



  public List<String>  diasdeTrabajo(){
   
int GUARDIACUATRO1 =16071;
SimpleDateFormat formato = new SimpleDateFormat("dd-MM-yyyy");
Calendar cal = GregorianCalendar.getInstance();
Date date = null;

  for (int i=0; i< dias.size() ; i++){
try {
date = formato.parse(dias.get(i));

} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
cal.setTime(date);
Long dia= cal.getTimeInMillis();
dia = dia/(1000*60*60*24);
dia =dia-GUARDIACUATRO1 ;
int seg2 = (int) (dia % 8);

if(seg2 == 1 || seg2 == 3|| seg2== 4){

list.add(dias.get(i)+"-CURRO");
}else{ 
list.add(dias.get(i)+"-WHITE");
      }
}

  return list;
 
           } 
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
if (row == null) {
LayoutInflater inflater = (LayoutInflater) _context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = inflater.inflate(R.layout.screen_gridcell, parent, false);
}

// Get a reference to the Day gridcell
gridcell = (Button) row.findViewById(R.id.calendar_day_gridcell);
gridcell.setOnClickListener(this);

// ACCOUNT FOR SPACING

Log.d(tag, "Current Day: " + getCurrentDayOfMonth());
       


  day_color = list.get(position).split("-");
  theday = day_color[0];
  themonth = day_color[1];
  theyear = day_color[2];
if ((!eventsPerMonthMap.isEmpty()) && (eventsPerMonthMap != null)) {
if (eventsPerMonthMap.containsKey(theday)) {
num_events_per_day = (TextView) row
.findViewById(R.id.num_events_per_day);
Integer numEvents = (Integer) eventsPerMonthMap.get(theday);
num_events_per_day.setText(numEvents.toString());
}
}

// Set the Day GridCell
gridcell.setText(theday);
gridcell.setTag(theday + "-" + themonth + "-" + theyear);
Log.d(tag, "Setting GridCell " + theday + "-" + themonth + "-"
+ theyear);
     
    textoprueba.setText("Estos son los dias de  del mes "+dias);
 
 
 


if (day_color[3].equals("GREY")) {
gridcell.setTextColor(getResources()
.getColor(R.color.lightgray));
}
if (day_color[3].equals("WHITE")) {
gridcell.setTextColor(getResources().getColor(
R.color.black));
}
if (day_color[3].equals("CURRO")) {
gridcell.setTextColor(getResources().getColor(R.color.orrange));
}



return row;

}

@Override
public void onClick(View view) {
String date_month_year = (String) view.getTag();
selectedDayMonthYearButton.setText("Selected: " + date_month_year);
Log.e("Selected date", date_month_year);
try {
Date parsedDate = dateFormatter.parse(date_month_year);
Log.d(tag, "Parsed Date: " + parsedDate.toString());

} catch (ParseException e) {
e.printStackTrace();
}

}


                                               
  /* int GUARDIAUNO6 =  16076;
  int GUARDIADOS7 = 16077;
  int GUARDIATRES8 = 16078;
  int GUARDIACUATRO1 =16071;
  int GUARDIACINCO2 = 16072;
  int GUARDIASEIS3 = 16073;
  int GUARDIASIETE4 = 16074;
  int GUARDIAOCHO5 = 16075;
 
  */

 
                                   

  public int getCurrentDayOfMonth() {
return currentDayOfMonth;
}

private void setCurrentDayOfMonth(int currentDayOfMonth) {
this.currentDayOfMonth = currentDayOfMonth;
}

public void setCurrentWeekDay(int currentWeekDay) {
this.currentWeekDay = currentWeekDay;
}

public int getCurrentWeekDay() {
return currentWeekDay;
}
}
}

19
Hola. Creo l arraylist dias igual que se creo list pero con el año mes y dia  del mes que aparece en pantalla. Cree un textview debajo del calendario para ver todas las salidas de mis pruebas.Te envio el codigo para que lo veas, pero lo que o entiendo ahora es lo del mensaje anterior.
Un saludo.
Código: [Seleccionar]
package com.examples;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

@TargetApi(3)
public class MyCalendarActivity extends Activity implements OnClickListener {
private static final String tag = "MyCalendarActivity";

private TextView currentMonth;
private Button selectedDayMonthYearButton;
private ImageView prevMonth;
private ImageView nextMonth;
private GridView calendarView;
private GridCellAdapter adapter;
private Calendar _calendar;
@SuppressLint("NewApi")
private int month, year;
@SuppressWarnings("unused")
@SuppressLint({ "NewApi", "NewApi", "NewApi", "NewApi" })
private final SimpleDateFormat dateFormatter = new SimpleDateFormat("dd-MM-yy");
private static final String dateTemplate = "MMMM yyyy";



private TextView textoprueba;
    long seg ;
  //  ArrayList<String> prueba = new ArrayList<String>();

private String  tamaño;
   
 
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_calendar_view);

_calendar = Calendar.getInstance(Locale.getDefault());
month = _calendar.get(Calendar.MONTH) + 1;
year = _calendar.get(Calendar.YEAR);
Log.d(tag, "Calendar Instance:= " + "Month: " + month + " " + "Year: "
+ year);

selectedDayMonthYearButton = (Button) this
.findViewById(R.id.selectedDayMonthYear);
selectedDayMonthYearButton.setText("Selected: ");

prevMonth = (ImageView) this.findViewById(R.id.prevMonth);
prevMonth.setOnClickListener(this);

currentMonth = (TextView) this.findViewById(R.id.currentMonth);
currentMonth.setText(DateFormat.format(dateTemplate,
_calendar.getTime()));
         
nextMonth = (ImageView) this.findViewById(R.id.nextMonth);
nextMonth.setOnClickListener(this);

calendarView = (GridView) this.findViewById(R.id.calendar);

// Initialised
adapter = new GridCellAdapter(getApplicationContext(),
R.id.calendar_day_gridcell, month, year);
adapter.notifyDataSetChanged();
calendarView.setAdapter(adapter);


textoprueba = (TextView)this.findViewById(R.id.textoPruebas);


//textoprueba.setText("Estos son los dias de  del mes "+pruebas());
}
/*public ArrayList<Integer> pruebas(){
prueba.add("202");
prueba.add("103");
prueba.add("225");
prueba.add("226");
prueba.add("302");
prueba.add("2");
ArrayList<Integer> result = new ArrayList<Integer>();
for(String stringValue :prueba) {
            try {
                //Convert String to Integer, and store it into integer array list.
                result.add(Integer.parseInt(stringValue));
            } catch(NumberFormatException nfe) {
               //System.out.println("Could not parse " + nfe);
                Log.w("NumberFormat", "Parsing failed! " + stringValue + " can not be an integer");
            }
        }       
return result;


}*/



/**
*
* @param month
* @param year
*/
private void setGridCellAdapterToDate(int month, int year) {
adapter = new GridCellAdapter(getApplicationContext(),
R.id.calendar_day_gridcell, month, year);
_calendar.set(year, month - 1, _calendar.get(Calendar.DAY_OF_MONTH));
currentMonth.setText(DateFormat.format(dateTemplate,
_calendar.getTime()));
adapter.notifyDataSetChanged();
calendarView.setAdapter(adapter);
}

@Override
public void onClick(View v) {
if (v == prevMonth) {
if (month <= 1) {
month = 12;
year--;
} else {
month--;
}
Log.d(tag, "Setting Prev Month in GridCellAdapter: " + "Month: "
+ month + " Year: " + year);
setGridCellAdapterToDate(month, year);
}
if (v == nextMonth) {
if (month > 11) {
month = 1;
year++;
} else {
month++;
}
Log.d(tag, "Setting Next Month in GridCellAdapter: " + "Month: "
+ month + " Year: " + year);
setGridCellAdapterToDate(month, year);
}

}

@Override
public void onDestroy() {
Log.d(tag, "Destroying View ...");
super.onDestroy();
}

// Inner Class
public class GridCellAdapter extends BaseAdapter implements OnClickListener {
private static final String tag = "GridCellAdapter";
private final Context _context;

private   List<String> list;
private static final int DAY_OFFSET = 1;
private final String[] weekdays = new String[] { "Sun", "Mon", "Tue",
"Wed", "Thu", "Fri", "Sat" };
//private final String[] months = { "January", "February", "March",
// "April", "May", "June", "July", "August", "September",
// "October", "November", "December" };
private final String[] months ={"00","01","02","03","04","05","06","07","08","09","10","11"};
private final int[] daysOfMonth = { 31, 28, 31, 30, 31, 30, 31, 31, 30,
31, 30, 31 };
private int daysInMonth;
private int currentDayOfMonth;
private int currentWeekDay;
private Button gridcell;
private TextView num_events_per_day;
private final HashMap<String, Integer> eventsPerMonthMap;
private final SimpleDateFormat dateFormatter = new SimpleDateFormat(
"dd-MM-yy"); //"dd-MMM-yyyy"


private   List<String>dias;
private   List<String>diaTrabajo;

   
 
 
// Days in Current Month
public GridCellAdapter(Context context, int textViewResourceId,
int month, int year) {
super();
this._context = context;
this.list = new ArrayList<String>();
Log.d(tag, "==> Passed in Date FOR Month: " + month + " "
+ "Year: " + year);
Calendar calendar = Calendar.getInstance();
setCurrentDayOfMonth(calendar.get(Calendar.DAY_OF_MONTH));
setCurrentWeekDay(calendar.get(Calendar.DAY_OF_WEEK));
Log.d(tag, "New Calendar:= " + calendar.getTime().toString());
Log.d(tag, "CurrentDayOfWeek :" + getCurrentWeekDay());
Log.d(tag, "CurrentDayOfMonth :" + getCurrentDayOfMonth());

this.dias = new ArrayList<String>();
this.diaTrabajo= new ArrayList<String>();
   
// Print Month
printMonth(month, year);

// Find Number of Events
eventsPerMonthMap = findNumberOfEventsPerMonth(year, month);

 

}

private String getMonthAsString(int i) {
return months[i];
}

private String getWeekDayAsString(int i) {
return weekdays[i];
}

private int getNumberOfDaysOfMonth(int i) {
return daysOfMonth[i];
}

public String getItem(int position) {
return list.get(position);
}



@Override
public int getCount() {
return list.size();
}

/**
* Prints Month
*
* @param mm
* @param yy
*/
private void printMonth(int mm, int yy) {
Log.d(tag, "==> printMonth: mm: " + mm + " " + "yy: " + yy);
int trailingSpaces = 0;
int daysInPrevMonth = 0;
int prevMonth = 0;
int prevYear = 0;
int nextMonth = 0;
int nextYear = 0;

int currentMonth = mm - 1;
String currentMonthName = getMonthAsString(currentMonth);
daysInMonth = getNumberOfDaysOfMonth(currentMonth);

Log.d(tag, "Current Month: " + " " + currentMonthName + " having "
+ daysInMonth + " days.");

GregorianCalendar cal = new GregorianCalendar(yy, currentMonth, 1);
Log.d(tag, "Gregorian Calendar:= " + cal.getTime().toString());

if (currentMonth == 11) {
prevMonth = currentMonth - 1;
daysInPrevMonth = getNumberOfDaysOfMonth(prevMonth);
nextMonth = 0;
prevYear = yy;
nextYear = yy + 1;
Log.d(tag, "*->PrevYear: " + prevYear + " PrevMonth:"
+ prevMonth + " NextMonth: " + nextMonth
+ " NextYear: " + nextYear);
} else if (currentMonth == 0) {
prevMonth = 11;
prevYear = yy - 1;
nextYear = yy;
daysInPrevMonth = getNumberOfDaysOfMonth(prevMonth);
nextMonth = 1;
Log.d(tag, "**--> PrevYear: " + prevYear + " PrevMonth:"
+ prevMonth + " NextMonth: " + nextMonth
+ " NextYear: " + nextYear);
} else {
prevMonth = currentMonth - 1;
nextMonth = currentMonth + 1;
nextYear = yy;
prevYear = yy;
daysInPrevMonth = getNumberOfDaysOfMonth(prevMonth);
Log.d(tag, "***---> PrevYear: " + prevYear + " PrevMonth:"
+ prevMonth + " NextMonth: " + nextMonth
+ " NextYear: " + nextYear);
}

int currentWeekDay = cal.get(Calendar.DAY_OF_WEEK) - 1;
trailingSpaces = currentWeekDay;

Log.d(tag, "Week Day:" + currentWeekDay + " is "
+ getWeekDayAsString(currentWeekDay));
Log.d(tag, "No. Trailing space to Add: " + trailingSpaces);
Log.d(tag, "No. of Days in Previous Month: " + daysInPrevMonth);

if (cal.isLeapYear(cal.get(Calendar.YEAR)))
if (mm == 2)
++daysInMonth;
else if (mm == 3)
++daysInPrevMonth;

// Trailing Month days
for (int i = 0; i < trailingSpaces; i++) {
Log.d(tag,
"PREV MONTH:= "
+ prevMonth
+ " => "
+ getMonthAsString(prevMonth)
+ " "
+ String.valueOf((daysInPrevMonth
- trailingSpaces + DAY_OFFSET)
+ i));
list.add(String
.valueOf((daysInPrevMonth - trailingSpaces + DAY_OFFSET)
+ i)
+ "-GREY"
+ "-"
+ getMonthAsString(prevMonth)
+ "-"
+ prevYear);
}

// Current Month Days
for (int i = 1; i <= daysInMonth; i++) {
Log.d(currentMonthName, String.valueOf(i) + " "
+ getMonthAsString(currentMonth) + " " + yy);






dias.add(yy+ "/"+getMonthAsString(currentMonth)+"/"+String.valueOf(i) );

if (i == getCurrentDayOfMonth()) {
list.add(String.valueOf(i) + "-BLUE" + "-"
+ getMonthAsString(currentMonth) + "-" + yy);
} else {
list.add(String.valueOf(i) + "-WHITE" + "-"
+ getMonthAsString(currentMonth) + "-" + yy);


}
}

// Leading Month days
for (int i = 0; i < list.size() % 7; i++) {
Log.d(tag, "NEXT MONTH:= " + getMonthAsString(nextMonth));
list.add(String.valueOf(i + 1) + "-GREY" + "-"
+ getMonthAsString(nextMonth) + "-" + nextYear);
}
}

/**
* NOTE: YOU NEED TO IMPLEMENT THIS PART Given the YEAR, MONTH, retrieve
* ALL entries from a SQLite database for that month. Iterate over the
* List of All entries, and get the dateCreated, which is converted into
* day.
*
* @param year
* @param month
* @return
*/
private HashMap<String, Integer> findNumberOfEventsPerMonth(int year,
int month) {
HashMap<String, Integer> map = new HashMap<String, Integer>();

return map;
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
if (row == null) {
LayoutInflater inflater = (LayoutInflater) _context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = inflater.inflate(R.layout.screen_gridcell, parent, false);
}

// Get a reference to the Day gridcell
gridcell = (Button) row.findViewById(R.id.calendar_day_gridcell);
gridcell.setOnClickListener(this);

// ACCOUNT FOR SPACING

Log.d(tag, "Current Day: " + getCurrentDayOfMonth());

String[] day_color = list.get(position).split("-");
String theday = day_color[0];
String themonth = day_color[2];
String theyear = day_color[3];
if ((!eventsPerMonthMap.isEmpty()) && (eventsPerMonthMap != null)) {
if (eventsPerMonthMap.containsKey(theday)) {
num_events_per_day = (TextView) row
.findViewById(R.id.num_events_per_day);
Integer numEvents = (Integer) eventsPerMonthMap.get(theday);
num_events_per_day.setText(numEvents.toString());
}
}

// Set the Day GridCell
gridcell.setText(theday);
gridcell.setTag(theday + "-" + themonth + "-" + theyear);
Log.d(tag, "Setting GridCell " + theday + "-" + themonth + "-"
+ theyear);
  // textoprueba.setText("Estos son los dias de  del mes "+list);
             textoprueba.setText("Estos son los dias de  del mes "+diasdeTrabajo());
           
if (day_color[1].equals("GREY")) {
gridcell.setTextColor(getResources()
.getColor(R.color.lightgray));
}
if (day_color[1].equals("WHITE")) {
gridcell.setTextColor(getResources().getColor(
R.color.lightgray02));
}
if (day_color[1].equals("BLUE")) {
gridcell.setTextColor(getResources().getColor(R.color.orrange));
}
return row;
}

@Override
public void onClick(View view) {
String date_month_year = (String) view.getTag();
selectedDayMonthYearButton.setText("Selected: " + date_month_year);
Log.e("Selected date", date_month_year);
try {
Date parsedDate = dateFormatter.parse(date_month_year);
Log.d(tag, "Parsed Date: " + parsedDate.toString());

} catch (ParseException e) {
e.printStackTrace();
}

}


  public List<String>  diasdeTrabajo(){
     
  int GUARDIACUATRO1 =16070;
  SimpleDateFormat formato = new SimpleDateFormat("yyyy/MM/dd");
  Calendar cal = GregorianCalendar.getInstance();
  Date date = null;
 
  for (int i=0;i < dias.size(); i++){
  try {
date = formato.parse(dias.get(i));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
  cal.setTime(date);
  Long dia= cal.getTimeInMillis();
  dia = dia/(1000*60*60*24);
  dia =dia-GUARDIACUATRO1;
  int seg2 = (int) (dia % 8);
 
  if(seg2 == 1 || seg2 == 3|| seg2== 4){
   
  diaTrabajo.add(dias.get(i)+ "-CURRO");
  }else{
 
  diaTrabajo.add(dias.get(i)+"-LIBRE");
 
  }
  return diaTrabajo;
       }
  /* int GUARDIAUNO6 =  16075;
  int GUARDIADOS7 = 16076;
  int GUARDIATRES8 = 16077;
  int GUARDIACUATRO1 =16070;
  int GUARDIACINCO2 = 16071;
  int GUARDIASEIS3 = 16072;
  int GUARDIASIETE4 = 16073;
  int GUARDIAOCHO5 = 16074;
 
  */

 

public int getCurrentDayOfMonth() {
return currentDayOfMonth;
}

private void setCurrentDayOfMonth(int currentDayOfMonth) {
this.currentDayOfMonth = currentDayOfMonth;
}

public void setCurrentWeekDay(int currentWeekDay) {
this.currentWeekDay = currentWeekDay;
}

public int getCurrentWeekDay() {
return currentWeekDay;
}
}
}
A parte adjunto un rar del calendario.

20
Referente al mensaje anterior en la linea       date = formato.parse(list.get(i));
tiene que ser    date = formato.parse(dias.get(i));

Perdon.

Páginas: [1] 2

Sobre la educación, sólo puedo decir que es el tema más importante en el que nosotros, como pueblo, debemos involucrarnos.

Abraham Lincoln (1808-1865) Presidente estadounidense.

aprenderaprogramar.com: Desde 2006 comprometidos con la didáctica y divulgación de la programación

Preguntas y respuestas

¿Cómo establecer o cambiar la imagen asociada (avatar) de usuario?
  1. Inicia sesión con tu nombre de usuario y contraseña.
  2. Pulsa en perfil --> perfil del foro
  3. Elige la imagen personalizada que quieras usar. Puedes escogerla de una galería de imágenes o subirla desde tu ordenador.
  4. En la parte final de la página pulsa el botón "cambiar perfil".