val navFragment = supportFragmentManager.findFragmentById(R.id.fragment)
val firstFragment = navFragment!!.childFragmentManager.primaryNavigationFragment
val myFragment: FirstFragment = firstFragment as FirstFragment
myFragment.sample()
theandroidcodings
Friday, August 19, 2022
Call Method Inside Fragment From Activity
Tuesday, April 30, 2019
Chage The MpChart Default Colour In Android
In Android If Chart Designed Using MpChart You Can Change The Default Color Easily,
In Chart Color is Set using This,
In Chart Color is Set using This,
ColorTemplate.COLORFUL_COLORS
Change Color:
1) Array Initialize:
int colors[] = {Color.RED,Color.GREEN,Color.BLACK,Color.BLUE};
2) Set To Chart Color:
bardataset.setColors(colors);
Increase The Time Using CountDownTimer Android
Button button;
EditText editText;
CountDownTimer timer; int min = 0; int sec = 0;button.setOnClickListener(new View.OnClickListener() { @Overridepublic void onClick(View v) { timer = new CountDownTimer(61000,1000) { @Overridepublic void onTick(long millisUntilFinished) { if (sec==59){ sec = 0; min = min+1; String text = String.format(Locale.getDefault(),"%02d min: %02d sec",min,sec); editText.setText(text); }else { sec = sec+1; String text = String.format(Locale.getDefault(),"%02d min: %02d sec",min,sec); editText.setText(text); } } @Override public void onFinish() { Toast.makeText(DesignActivity.this, "Timer Stopped...", Toast.LENGTH_SHORT).show(); } }; timer.start(); } });
Time And Date Pickers In Android
In This Example We See Get Data From Time Picker And Date Picker One by One.
TimePickerDialog timePickerDialog; int hour1,minutes1; int cYear,cMonth,cDay;editText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Calendar getDate = Calendar.getInstance(); cDay = getDate.get(Calendar.DAY_OF_MONTH); cMonth = getDate.get(Calendar.MONTH); cYear = getDate.get(Calendar.YEAR); timePickerDialog = new TimePickerDialog(DesignActivity.this, new TimePickerDialog. OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { final String AM_PM ; if (hourOfDay > 12) { hourOfDay -= 12; AM_PM = "pm"; } else if (hourOfDay == 0) { hourOfDay += 12; AM_PM = "am"; } else if (hourOfDay == 12) AM_PM = "pm"; else AM_PM = "am"; hour1 = hourOfDay; minutes1 = minute; DatePickerDialog datePicker =new DatePickerDialog(DesignActivity.this, new DatePickerDialog. OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) { cYear = year; cMonth = month; cDay = dayOfMonth; editText.setText(hour1 + ":" +minutes1 + AM_PM + " " + cDay + "/" + cMonth + "/" + cYear); } },cYear,cMonth,cDay); datePicker.show(); } },hour1,minutes1,false); timePickerDialog.show(); } });
Sunday, April 21, 2019
Android Move One Activity To Another
In Android To Move One Activity To Another Activity Using Intent.
Two Types of Intent:
1) Explicit Intent.
2) Implicit Intent.
1) Explicit Intent:
Moving With In Your Application.
2) Implicit Intent:
Access Outside of Your Application.
(E.X) Access Camera,Gallery on Your Mobile.
So, We Can Use Explicit Intent To Solve This,
Two Types of Intent:
1) Explicit Intent.
2) Implicit Intent.
1) Explicit Intent:
Moving With In Your Application.
2) Implicit Intent:
Access Outside of Your Application.
(E.X) Access Camera,Gallery on Your Mobile.
So, We Can Use Explicit Intent To Solve This,
Intent intent = new Intent(this,SecondActivity.class);
startActivity(intent);
this --> refers to the current activity.
SecondActivity.class --> Where to You Go.
startActivity --> Start The SecondActivity From Your Current Activity.
Subscribe to:
Posts (Atom)