TimePicker nimmt nicht die ausgewählte Zeit

kukuk

kukuk

App-Anbieter (kostenlos)
29
Hallo zusammen, ich habe mir einen Dialog mit 2 TimePicker gebastelt.

Wenn ich den Code ausführe, wird der erste Time Picker richtig ausgelesen, aber der 2. nicht. Bei dem 2. wird immer die aktuelle minuten Zeit wiedergegeben.
Kann mir jemand helfen, wo sich mein Fehler versteckt hat?

Code:
 Global.von_bis_auswahl = false;
				 			 Global.von_h =0;
				 	    	 Global.von_min = 0;
				 	    	 Global.bis_h = 0;
				 	    	 Global.bis_min = 0;
				 				
				 				AlertDialog.Builder alert = new AlertDialog.Builder(this);
				 				String positiveButton = "";
				 				String negativeButton = "";
				 				if (Global.is_german){
				 			    alert.setTitle("Zeitraum der Überstunden Festlegen");

				 			   
				 			    positiveButton = "Ok";
				 				negativeButton = "Abbrechen";
				 				}else{
				 			        alert.setTitle("Enter Period of your overtime");

				 			       
				 			        positiveButton = "Ok";
				 			    	negativeButton = "Cancel";
				 				}
				 				final  TimePicker von = new TimePicker(this);
				 				
				 				
				 			
				 				ScrollView scroll = new ScrollView(this);
				 			
				 				final  TimePicker bis = new TimePicker(this);
				 				
				 				
				 				final  TextView text = new TextView(this);
				 				final  TextView txt_von = new TextView(this);
				 				final  TextView txt_bis = new TextView(this);
				 			    // Set an EditText view to get user input 
				 				
				 				von.setIs24HourView(true);
				 				bis.setIs24HourView(true);
				 			    text.setText("Bitte wählen Sie Ihre von- bis Uhrzeit der Überstunden aus. Klicken sie auf abbrechen, wenn Sie die Werte von Hand eingeben wollen.");
				 				txt_von.setText("Von:");
				 			    txt_bis.setText("Bis:");
				 			    LinearLayout lay = new LinearLayout(this);
				 			    
				 			    lay.setOrientation(LinearLayout.VERTICAL);
				 			   
				 			    lay.addView(text);
				 			    lay.addView(txt_von);
				 			    lay.addView(von);
				 			    lay.addView(txt_bis);
				 			    lay.addView(bis);
				 			    scroll.setBackgroundColor(android.R.color.transparent);
				 			    scroll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
				 			  scroll.addView(lay);
				 			 
				 			    alert.setView(scroll);
				 			   

				 			 
				 			    alert.setPositiveButton("" + positiveButton, new DialogInterface.OnClickListener() {
				 			    public void onClick(DialogInterface dialog, int whichButton) {
				 			    	
				 			    	 Global.von_h = von.getCurrentHour();
				 			    	 Global.von_min = von.getCurrentMinute();
				 			    	 Global.bis_h = bis.getCurrentHour();
				 			    	 Global.bis_min = bis.getCurrentMinute();
				 			    	 
				 			    	 if (Global.bis_h < Global.von_h){
				 			    		 toast_nicht_moeglich();
				 			    	 }else{
				 			    		 if (!(Global.bis_min < Global.von_min && Global.bis_h < Global.von_h)){
				 			    		 Global.von_bis_auswahl = true;
				 			    		von_bis_zeit_setzen();
				 			    		 }else{
				 			    			toast_nicht_moeglich();	 
				 			    		 }
				 			    	 }
				 			    	 dialog.dismiss();
				 			      // Do something with value!
				 			      }
				 			    });
				 			    alert.setNegativeButton("" + negativeButton, new DialogInterface.OnClickListener() {
				 			    public void onClick(DialogInterface dialog, int whichButton) {
				 			    	Global.von_bis_auswahl = false;
				 			    	
				 			dialog.dismiss();
				 			      // Do something with value!
				 			      }
				 			    });
				 			    alert.show();
				 			    







public void von_bis_zeit_setzen(){
				int zwischenwert1 = 0;
				int zwischenwert2 = 0;
				TextView txt_h = (TextView)findViewById(R.id.editText1);
				TextView txt_min = (TextView)findViewById(R.id.EditText3);

				TextView zeitraum = (TextView)findViewById(R.id.EditText4);
				
			if (Global.von_bis_auswahl){
				String hilfswert1 = "";
				String hilfswert2 = "";
				String hilfswert3 = "";
				String hilfswert4 = "";
				if (Global.von_min < 10){
					hilfswert1 = "0" + Global.von_min;
				}else{
					hilfswert1 = ""+Global.von_min;
				}
				
				if (Global.bis_min < 10){
					hilfswert2 = "0" + Global.bis_min;
				}else{
					hilfswert2 = ""+Global.bis_min;
				}
				
				if (Global.von_h < 10){
					hilfswert3 = "0" + Global.von_h;
				}else{
					hilfswert3 = ""+Global.von_h;
				}
				
				if (Global.bis_h < 10){
					hilfswert4 = "0" + Global.bis_h;
				}else{
					hilfswert4 = ""+Global.bis_h;
				}
				
				zeitraum.setText(""+ hilfswert3 + ":" + hilfswert1 + " - " + Global.bis_h + ":"+ hilfswert4 + " Uhr");
			}
			Global.von_bis_auswahl = false;
				zwischenwert1 = (Global.bis_h - Global.von_h);
				zwischenwert2 = (Global.bis_min - Global.von_min);
				
				if (zwischenwert2 < 0){
					zwischenwert1 -=1;
					zwischenwert2 = (60 + zwischenwert2);
				}
				txt_h.setText("" + zwischenwert1);
				txt_min.setText("" + zwischenwert2);
				
			
				
			}
 

Ähnliche Themen

J
Antworten
5
Aufrufe
930
swa00
swa00
B
Antworten
3
Aufrufe
912
jogimuc
J
G
Antworten
0
Aufrufe
399
gnome2012
G
Zurück
Oben Unten