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:

Así Aparece En Mi Smartphone:

Codigo xml:
Codigo Java:
Y se pone muy lento al interactuar con la interfaz, nose que sera.
Agradesco Muchísimo Su Apoyo Gracias.
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:

Así Aparece En Mi Smartphone:

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


0