Android - No Puedo Mostrar un CalendarView en mi smartphone

 
Vista:
sin imagen de perfil
Val: 1
Ha aumentado su posición en 82 puestos en Android (en relación al último mes)
Gráfica de Android

No Puedo Mostrar un CalendarView en mi smartphone

Publicado por Juan (1 intervención) el 03/06/2018 23:21:15
Hola a todos, Gracias Por Esta Aquí..

Estoy haciendo un proyecto en Android studio utilizando un CalendarView y otros componentes.

El problema es que no me muestra el calendar View al ejecutarlo en mi Smarthpone, pero cuando lo ejecuto desde el emulador si aparece.

Así Aparece en el EMULADOR DE ANDROID Studio:

Screenshot_1528060192


Así Aparece En Mi Smartphone:


2018-06-03-16.14.48


Codigo xml:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.jdp.juanprieto.registropasajes.MainActivity">
 
 
    <com.github.clans.fab.FloatingActionMenu
        android:id="@+id/fabprincipal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        app:menu_fab_label="Menu">
 
        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/fabadd"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/ic_registro_add"
            app:fab_label="Agregar" />
        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/fabprueba"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/ic_registro_add"
            app:fab_label="Prueba"
            android:onClick="fabprub"/>
    </com.github.clans.fab.FloatingActionMenu>
 
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
 
        <CalendarView
            android:id="@+id/calendarViewmain"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
 
        <TextView
            android:id="@+id/Estadotxt"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Estado"
            android:textSize="40dp" />
 
        <TextView
            android:id="@+id/descriptxt"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Descripcion"
            android:textSize="15dp" />
 
 
 
 
    </LinearLayout>
 
 
</RelativeLayout>


Codigo Java:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
public class MainActivity extends AppCompatActivity {
    FloatingActionMenu fabmenu;
    FloatingActionButton fabadd;
    TextView estado,descripcion;
    CalendarView calendarView;
    String fecha;
 
 
    @Override
    protected void onResume() {
        super.onResume();
 
    }
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
 
        //Widgets
        fabmenu = (FloatingActionMenu) findViewById(R.id.fabprincipal);
        fabmenu.setClosedOnTouchOutside(true);
        fabadd = (FloatingActionButton) findViewById(R.id.fabadd);
        estado = (TextView) findViewById(R.id.Estadotxt);
        descripcion=(TextView)findViewById(R.id.descriptxt);
        calendarView = (CalendarView) findViewById(R.id.calendarViewmain);
 
 
 
 
        calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
            @Override
            public void onSelectedDayChange(@NonNull CalendarView view, int year, int month , int dayOfMonth) {
              fecha=dayOfMonth+"/"+(month+1)+"/"+year;
                  MostrarDatos(fecha);
            }
        });
 
        fabadd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if  (fecha!=null){
                }
                else{
                    //Formato
                    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
                    //Guardar En Long
                   long Fecha=calendarView.getDate();
                   //Date
                    Date outFecReg = new Date(Fecha);
                    fecha = sdf.format(outFecReg);
                }
 
 
 
 
 
Intent intent=new Intent(MainActivity.this, AgregarRegistro.class);
                intent.putExtra("Fecha",fecha);
startActivity(intent);
 
 
            }
        });
 
    }
 
    public void MostrarDatos(String FECHA){
        long newfecha = 0;
//Pasar De Date A Long
        SimpleDateFormat format=new SimpleDateFormat("dd/MM/yyyy");
        try {
            Date date = format.parse(FECHA);
            newfecha=date.getTime();
        } catch (ParseException e) {
            e.printStackTrace();
        }
 
DataBaseHelper dataBaseHelper=new DataBaseHelper(this);
SQLiteDatabase db=dataBaseHelper.getWritableDatabase();
Cursor cursor=db.rawQuery("SELECT FECHA, TIPO, DESCRIPCION FROM REGISTRO WHERE FECHA = '"+newfecha+"'"  ,null);
if(cursor.moveToFirst()){
 
    estado.setText(cursor.getString(1));
    descripcion.setText(cursor.getString(2));
 
}else {
    Toast.makeText(this,"No hay registro",Toast.LENGTH_SHORT).show();
 
}
db.close();
 
 
 
 
 
 
 
    }
 
    public  void fabprub(View view){
 
        Intent intent=new Intent(MainActivity.this, prueba.class);
        startActivity(intent);
 
    }
 
}


Y se pone muy lento al interactuar con la interfaz, nose que sera.

Agradesco Muchísimo Su Apoyo Gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

No Puedo Mostrar un CalendarView en mi smartphone

Publicado por Rafael Rodríguez (1 intervención) el 03/06/2020 08:38:50
Hola, que tal, he tenido el mismo error y lo y la solucion que encontré fue en StackoverFlow del siguiente enlace: https://stackoverflow.com/questions/43305590/calendarview-is-displayed-differently-in-android-studio-emulator-mobile-appl


En conclusión lo que necesitas hacer es instalar o poner un tema al calendar view, intenta con algo como esto:

android:theme="@style/Theme.AppCompat.Light"
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar