Unable to get ViewModel instance in RecyclerView.Adapter class KotlinCreate an instance of an abstract class in KotlinHandling countdown timers in recyclerview - androidRecyclerView changing position randomly while scrollingUnable to set ViewModel on KotlinHow to update all live data the same time?Android MVVM: Does using Glide directly in a fragment break the MVVM pattern?Android - LiveData is not unsubscribed when fragment is refreshedMVVM - custom tab layout control with LiveDataCreate ViewModel with Application

Create the same subfolders in another folder

Why is STARTTLS still used?

How to prevent pickpocketing in busy bars?

Optimize a query reducing logical reads

What are examples of EU policies that are beneficial for one EU country, disadvantagious for another?

What in my code changed between MacTeX 2017 and MacTex 2019?

What's the use case of commercial optimizer when we have Tensorflow?

What is Weapon Handling?

Why is a road bike faster than a city bike with the same effort? How much faster it can be?

Magento 2: Add active class on selected shipping method

Can you trip a breaker from a different circuit?

I reverse the source code, you reverse the input!

How deep is the liquid in a half-full hemisphere?

Would an object shot from earth fall into the sun?

How to adjust OS print output to different screen dimensions on VIC-20?

Equations with summation ("sum") symbols

Why, even after his imprisonment, people keep calling Hannibal Lecter "Doctor"?

How can I find Marin?

How can the dynamic linker/loader itself be dynamically linked as reported by `file`?

Convert a string of digits from words to an integer

Do interval ratios take overtones into account or solely the fundamental frequency?

Is population size a parameter, or sample size a statistic?

Is it ok if I haven't decided my research topic when I first meet with a potential phd advisor?

Notebook with version-dependent cells



Unable to get ViewModel instance in RecyclerView.Adapter class Kotlin


Create an instance of an abstract class in KotlinHandling countdown timers in recyclerview - androidRecyclerView changing position randomly while scrollingUnable to set ViewModel on KotlinHow to update all live data the same time?Android MVVM: Does using Glide directly in a fragment break the MVVM pattern?Android - LiveData is not unsubscribed when fragment is refreshedMVVM - custom tab layout control with LiveDataCreate ViewModel with Application






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm new in kotlin and trying to create alarm clock app. In this app I using LiveData and RecycleView. Right now I need to change alarm status:



switcher



Here is my AlarmsRecyclerAdapter where i tried to create .onClickListener



override fun onBindViewHolder(holder: AlarmsRecyclerAdapter.AlarmItemHolder, position: Int) 
//mAlarmViewModel = ViewModelProviders.of( context as Fragment)[AlarmViewModel::class.java]
if (mAlarms != null)
val current = mAlarms!!.get(position)
holder.view.edit_time_button.text = current.printTime()
holder.view.switch_alarm_enabled.isEnabled = current.enabled

holder.view.switch_alarm_enabled.setOnClickListener
current.enabled = !current.enabled
// mAlarmViewModel.insert(current)

else
// Covers the case of data not being ready yet.
holder.view.edit_time_button.text = "no timer"




Also i tried to get instance of ViewModel in comment line, but it just throws errors like




java.lang.ClassCastException: android.app.Application cannot be cast to androidx.fragment.app.FragmentActivity
at com.xxx.alarm.AlarmsRecyclerAdapter.onBindViewHolder(AlarmsRecyclerAdapter.kt:58)
at com.xxx.alarm.AlarmsRecyclerAdapter.onBindViewHolder(AlarmsRecyclerAdapter.kt:33)




I need change alarms in Database. So how can I get instance of ViewMoedel in adapter class? Or is there better way to manage data changing?










share|improve this question
































    0















    I'm new in kotlin and trying to create alarm clock app. In this app I using LiveData and RecycleView. Right now I need to change alarm status:



    switcher



    Here is my AlarmsRecyclerAdapter where i tried to create .onClickListener



    override fun onBindViewHolder(holder: AlarmsRecyclerAdapter.AlarmItemHolder, position: Int) 
    //mAlarmViewModel = ViewModelProviders.of( context as Fragment)[AlarmViewModel::class.java]
    if (mAlarms != null)
    val current = mAlarms!!.get(position)
    holder.view.edit_time_button.text = current.printTime()
    holder.view.switch_alarm_enabled.isEnabled = current.enabled

    holder.view.switch_alarm_enabled.setOnClickListener
    current.enabled = !current.enabled
    // mAlarmViewModel.insert(current)

    else
    // Covers the case of data not being ready yet.
    holder.view.edit_time_button.text = "no timer"




    Also i tried to get instance of ViewModel in comment line, but it just throws errors like




    java.lang.ClassCastException: android.app.Application cannot be cast to androidx.fragment.app.FragmentActivity
    at com.xxx.alarm.AlarmsRecyclerAdapter.onBindViewHolder(AlarmsRecyclerAdapter.kt:58)
    at com.xxx.alarm.AlarmsRecyclerAdapter.onBindViewHolder(AlarmsRecyclerAdapter.kt:33)




    I need change alarms in Database. So how can I get instance of ViewMoedel in adapter class? Or is there better way to manage data changing?










    share|improve this question




























      0












      0








      0








      I'm new in kotlin and trying to create alarm clock app. In this app I using LiveData and RecycleView. Right now I need to change alarm status:



      switcher



      Here is my AlarmsRecyclerAdapter where i tried to create .onClickListener



      override fun onBindViewHolder(holder: AlarmsRecyclerAdapter.AlarmItemHolder, position: Int) 
      //mAlarmViewModel = ViewModelProviders.of( context as Fragment)[AlarmViewModel::class.java]
      if (mAlarms != null)
      val current = mAlarms!!.get(position)
      holder.view.edit_time_button.text = current.printTime()
      holder.view.switch_alarm_enabled.isEnabled = current.enabled

      holder.view.switch_alarm_enabled.setOnClickListener
      current.enabled = !current.enabled
      // mAlarmViewModel.insert(current)

      else
      // Covers the case of data not being ready yet.
      holder.view.edit_time_button.text = "no timer"




      Also i tried to get instance of ViewModel in comment line, but it just throws errors like




      java.lang.ClassCastException: android.app.Application cannot be cast to androidx.fragment.app.FragmentActivity
      at com.xxx.alarm.AlarmsRecyclerAdapter.onBindViewHolder(AlarmsRecyclerAdapter.kt:58)
      at com.xxx.alarm.AlarmsRecyclerAdapter.onBindViewHolder(AlarmsRecyclerAdapter.kt:33)




      I need change alarms in Database. So how can I get instance of ViewMoedel in adapter class? Or is there better way to manage data changing?










      share|improve this question
















      I'm new in kotlin and trying to create alarm clock app. In this app I using LiveData and RecycleView. Right now I need to change alarm status:



      switcher



      Here is my AlarmsRecyclerAdapter where i tried to create .onClickListener



      override fun onBindViewHolder(holder: AlarmsRecyclerAdapter.AlarmItemHolder, position: Int) 
      //mAlarmViewModel = ViewModelProviders.of( context as Fragment)[AlarmViewModel::class.java]
      if (mAlarms != null)
      val current = mAlarms!!.get(position)
      holder.view.edit_time_button.text = current.printTime()
      holder.view.switch_alarm_enabled.isEnabled = current.enabled

      holder.view.switch_alarm_enabled.setOnClickListener
      current.enabled = !current.enabled
      // mAlarmViewModel.insert(current)

      else
      // Covers the case of data not being ready yet.
      holder.view.edit_time_button.text = "no timer"




      Also i tried to get instance of ViewModel in comment line, but it just throws errors like




      java.lang.ClassCastException: android.app.Application cannot be cast to androidx.fragment.app.FragmentActivity
      at com.xxx.alarm.AlarmsRecyclerAdapter.onBindViewHolder(AlarmsRecyclerAdapter.kt:58)
      at com.xxx.alarm.AlarmsRecyclerAdapter.onBindViewHolder(AlarmsRecyclerAdapter.kt:33)




      I need change alarms in Database. So how can I get instance of ViewMoedel in adapter class? Or is there better way to manage data changing?







      android mvvm kotlin android-recyclerview






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 19:48







      Michael

















      asked Mar 28 at 19:03









      MichaelMichael

      599 bronze badges




      599 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          1
















          Not really sure about getting your ViewModel inside your RecyclerView, and not really sure if this would be considered best practice. But here is the way I am doing this, and have others seen doing it.
          First you create your ViewModel in you Fragment.
          Then you observe your AlarmData and when it changes you update the data in your RecyclerAdapter.



          So in your Fragment you do something like this():



          mAlarmViewModel = ViewModelProviders.of( context as Fragment)[AlarmViewModel::class.java]
          mAlarmViewMode.getAlarms().observe(...
          mAdapter.setData(newData)


          and inside you Adapter you add the following:



          setData(data:List) 
          mAlarms= data;
          notifyDataSetChanged();



          this should keep your data updated.



          Now for the changing of your data.
          Try Setting the OnclickListener inside your ViewHolder, as this is going to increase the speed of your app.
          to get your current value you could do this:



          val current = mAlarms!!.get(getAdapterPosition())


          Finally you shold add a Interface to your Adapter, something like this:



          interface ItemSelectedListener 
          fun onItemSelected(item:Any, v:View)



          Set this interface from your Fragment and call it from the onClickListener.
          Then you have all the data you need inside your Fragment and can modify it from there






          share|improve this answer

























          • thanks for your reply. Actually i need change my alarms in database, so thats why i need that ViewModel instance. If I change them in DB it should changes in frontend because of LiveData.

            – Michael
            Mar 28 at 19:55











          • So I am guessing you are using Room and LifeData too? When you are changing something in your database, the Observer from you LifeDataObject will trigger, and update you recyclerview.

            – glm9637
            Mar 28 at 19:57











          • Ye, you're right. But i cant get instance of ViewModel to use database like this mAlarmViewModel.insert(current). In Fragment class i can get instance in this way mAlarmViewModel = ViewModelProviders.of(this)[AlarmViewModel::class.java] but I need to pass some parameter to method .of() to get instance in AlarmsRecyclerAdapter class.

            – Michael
            Mar 28 at 20:06












          • Like I said, you could just move the data modification to your Fragment, there you would have everything you need. If you really need to get the ViewModel inside your Recyclerview, just pass your Fragment as additional Argument in the constructor and use this reference, to get you ViewModel.

            – glm9637
            Mar 28 at 20:09











          • thanks a lot! Could you please explain me in which way i can move data modification to Fragment? I need my data be modified when switcher clicked and i can handle it only in AlarmsRecyclerAdapter class. Am I wrong?

            – Michael
            Mar 28 at 20:21














          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405112%2funable-to-get-viewmodel-instance-in-recyclerview-adapter-class-kotlin%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1
















          Not really sure about getting your ViewModel inside your RecyclerView, and not really sure if this would be considered best practice. But here is the way I am doing this, and have others seen doing it.
          First you create your ViewModel in you Fragment.
          Then you observe your AlarmData and when it changes you update the data in your RecyclerAdapter.



          So in your Fragment you do something like this():



          mAlarmViewModel = ViewModelProviders.of( context as Fragment)[AlarmViewModel::class.java]
          mAlarmViewMode.getAlarms().observe(...
          mAdapter.setData(newData)


          and inside you Adapter you add the following:



          setData(data:List) 
          mAlarms= data;
          notifyDataSetChanged();



          this should keep your data updated.



          Now for the changing of your data.
          Try Setting the OnclickListener inside your ViewHolder, as this is going to increase the speed of your app.
          to get your current value you could do this:



          val current = mAlarms!!.get(getAdapterPosition())


          Finally you shold add a Interface to your Adapter, something like this:



          interface ItemSelectedListener 
          fun onItemSelected(item:Any, v:View)



          Set this interface from your Fragment and call it from the onClickListener.
          Then you have all the data you need inside your Fragment and can modify it from there






          share|improve this answer

























          • thanks for your reply. Actually i need change my alarms in database, so thats why i need that ViewModel instance. If I change them in DB it should changes in frontend because of LiveData.

            – Michael
            Mar 28 at 19:55











          • So I am guessing you are using Room and LifeData too? When you are changing something in your database, the Observer from you LifeDataObject will trigger, and update you recyclerview.

            – glm9637
            Mar 28 at 19:57











          • Ye, you're right. But i cant get instance of ViewModel to use database like this mAlarmViewModel.insert(current). In Fragment class i can get instance in this way mAlarmViewModel = ViewModelProviders.of(this)[AlarmViewModel::class.java] but I need to pass some parameter to method .of() to get instance in AlarmsRecyclerAdapter class.

            – Michael
            Mar 28 at 20:06












          • Like I said, you could just move the data modification to your Fragment, there you would have everything you need. If you really need to get the ViewModel inside your Recyclerview, just pass your Fragment as additional Argument in the constructor and use this reference, to get you ViewModel.

            – glm9637
            Mar 28 at 20:09











          • thanks a lot! Could you please explain me in which way i can move data modification to Fragment? I need my data be modified when switcher clicked and i can handle it only in AlarmsRecyclerAdapter class. Am I wrong?

            – Michael
            Mar 28 at 20:21
















          1
















          Not really sure about getting your ViewModel inside your RecyclerView, and not really sure if this would be considered best practice. But here is the way I am doing this, and have others seen doing it.
          First you create your ViewModel in you Fragment.
          Then you observe your AlarmData and when it changes you update the data in your RecyclerAdapter.



          So in your Fragment you do something like this():



          mAlarmViewModel = ViewModelProviders.of( context as Fragment)[AlarmViewModel::class.java]
          mAlarmViewMode.getAlarms().observe(...
          mAdapter.setData(newData)


          and inside you Adapter you add the following:



          setData(data:List) 
          mAlarms= data;
          notifyDataSetChanged();



          this should keep your data updated.



          Now for the changing of your data.
          Try Setting the OnclickListener inside your ViewHolder, as this is going to increase the speed of your app.
          to get your current value you could do this:



          val current = mAlarms!!.get(getAdapterPosition())


          Finally you shold add a Interface to your Adapter, something like this:



          interface ItemSelectedListener 
          fun onItemSelected(item:Any, v:View)



          Set this interface from your Fragment and call it from the onClickListener.
          Then you have all the data you need inside your Fragment and can modify it from there






          share|improve this answer

























          • thanks for your reply. Actually i need change my alarms in database, so thats why i need that ViewModel instance. If I change them in DB it should changes in frontend because of LiveData.

            – Michael
            Mar 28 at 19:55











          • So I am guessing you are using Room and LifeData too? When you are changing something in your database, the Observer from you LifeDataObject will trigger, and update you recyclerview.

            – glm9637
            Mar 28 at 19:57











          • Ye, you're right. But i cant get instance of ViewModel to use database like this mAlarmViewModel.insert(current). In Fragment class i can get instance in this way mAlarmViewModel = ViewModelProviders.of(this)[AlarmViewModel::class.java] but I need to pass some parameter to method .of() to get instance in AlarmsRecyclerAdapter class.

            – Michael
            Mar 28 at 20:06












          • Like I said, you could just move the data modification to your Fragment, there you would have everything you need. If you really need to get the ViewModel inside your Recyclerview, just pass your Fragment as additional Argument in the constructor and use this reference, to get you ViewModel.

            – glm9637
            Mar 28 at 20:09











          • thanks a lot! Could you please explain me in which way i can move data modification to Fragment? I need my data be modified when switcher clicked and i can handle it only in AlarmsRecyclerAdapter class. Am I wrong?

            – Michael
            Mar 28 at 20:21














          1














          1










          1









          Not really sure about getting your ViewModel inside your RecyclerView, and not really sure if this would be considered best practice. But here is the way I am doing this, and have others seen doing it.
          First you create your ViewModel in you Fragment.
          Then you observe your AlarmData and when it changes you update the data in your RecyclerAdapter.



          So in your Fragment you do something like this():



          mAlarmViewModel = ViewModelProviders.of( context as Fragment)[AlarmViewModel::class.java]
          mAlarmViewMode.getAlarms().observe(...
          mAdapter.setData(newData)


          and inside you Adapter you add the following:



          setData(data:List) 
          mAlarms= data;
          notifyDataSetChanged();



          this should keep your data updated.



          Now for the changing of your data.
          Try Setting the OnclickListener inside your ViewHolder, as this is going to increase the speed of your app.
          to get your current value you could do this:



          val current = mAlarms!!.get(getAdapterPosition())


          Finally you shold add a Interface to your Adapter, something like this:



          interface ItemSelectedListener 
          fun onItemSelected(item:Any, v:View)



          Set this interface from your Fragment and call it from the onClickListener.
          Then you have all the data you need inside your Fragment and can modify it from there






          share|improve this answer













          Not really sure about getting your ViewModel inside your RecyclerView, and not really sure if this would be considered best practice. But here is the way I am doing this, and have others seen doing it.
          First you create your ViewModel in you Fragment.
          Then you observe your AlarmData and when it changes you update the data in your RecyclerAdapter.



          So in your Fragment you do something like this():



          mAlarmViewModel = ViewModelProviders.of( context as Fragment)[AlarmViewModel::class.java]
          mAlarmViewMode.getAlarms().observe(...
          mAdapter.setData(newData)


          and inside you Adapter you add the following:



          setData(data:List) 
          mAlarms= data;
          notifyDataSetChanged();



          this should keep your data updated.



          Now for the changing of your data.
          Try Setting the OnclickListener inside your ViewHolder, as this is going to increase the speed of your app.
          to get your current value you could do this:



          val current = mAlarms!!.get(getAdapterPosition())


          Finally you shold add a Interface to your Adapter, something like this:



          interface ItemSelectedListener 
          fun onItemSelected(item:Any, v:View)



          Set this interface from your Fragment and call it from the onClickListener.
          Then you have all the data you need inside your Fragment and can modify it from there







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 28 at 19:34









          glm9637glm9637

          7296 silver badges17 bronze badges




          7296 silver badges17 bronze badges















          • thanks for your reply. Actually i need change my alarms in database, so thats why i need that ViewModel instance. If I change them in DB it should changes in frontend because of LiveData.

            – Michael
            Mar 28 at 19:55











          • So I am guessing you are using Room and LifeData too? When you are changing something in your database, the Observer from you LifeDataObject will trigger, and update you recyclerview.

            – glm9637
            Mar 28 at 19:57











          • Ye, you're right. But i cant get instance of ViewModel to use database like this mAlarmViewModel.insert(current). In Fragment class i can get instance in this way mAlarmViewModel = ViewModelProviders.of(this)[AlarmViewModel::class.java] but I need to pass some parameter to method .of() to get instance in AlarmsRecyclerAdapter class.

            – Michael
            Mar 28 at 20:06












          • Like I said, you could just move the data modification to your Fragment, there you would have everything you need. If you really need to get the ViewModel inside your Recyclerview, just pass your Fragment as additional Argument in the constructor and use this reference, to get you ViewModel.

            – glm9637
            Mar 28 at 20:09











          • thanks a lot! Could you please explain me in which way i can move data modification to Fragment? I need my data be modified when switcher clicked and i can handle it only in AlarmsRecyclerAdapter class. Am I wrong?

            – Michael
            Mar 28 at 20:21


















          • thanks for your reply. Actually i need change my alarms in database, so thats why i need that ViewModel instance. If I change them in DB it should changes in frontend because of LiveData.

            – Michael
            Mar 28 at 19:55











          • So I am guessing you are using Room and LifeData too? When you are changing something in your database, the Observer from you LifeDataObject will trigger, and update you recyclerview.

            – glm9637
            Mar 28 at 19:57











          • Ye, you're right. But i cant get instance of ViewModel to use database like this mAlarmViewModel.insert(current). In Fragment class i can get instance in this way mAlarmViewModel = ViewModelProviders.of(this)[AlarmViewModel::class.java] but I need to pass some parameter to method .of() to get instance in AlarmsRecyclerAdapter class.

            – Michael
            Mar 28 at 20:06












          • Like I said, you could just move the data modification to your Fragment, there you would have everything you need. If you really need to get the ViewModel inside your Recyclerview, just pass your Fragment as additional Argument in the constructor and use this reference, to get you ViewModel.

            – glm9637
            Mar 28 at 20:09











          • thanks a lot! Could you please explain me in which way i can move data modification to Fragment? I need my data be modified when switcher clicked and i can handle it only in AlarmsRecyclerAdapter class. Am I wrong?

            – Michael
            Mar 28 at 20:21

















          thanks for your reply. Actually i need change my alarms in database, so thats why i need that ViewModel instance. If I change them in DB it should changes in frontend because of LiveData.

          – Michael
          Mar 28 at 19:55





          thanks for your reply. Actually i need change my alarms in database, so thats why i need that ViewModel instance. If I change them in DB it should changes in frontend because of LiveData.

          – Michael
          Mar 28 at 19:55













          So I am guessing you are using Room and LifeData too? When you are changing something in your database, the Observer from you LifeDataObject will trigger, and update you recyclerview.

          – glm9637
          Mar 28 at 19:57





          So I am guessing you are using Room and LifeData too? When you are changing something in your database, the Observer from you LifeDataObject will trigger, and update you recyclerview.

          – glm9637
          Mar 28 at 19:57













          Ye, you're right. But i cant get instance of ViewModel to use database like this mAlarmViewModel.insert(current). In Fragment class i can get instance in this way mAlarmViewModel = ViewModelProviders.of(this)[AlarmViewModel::class.java] but I need to pass some parameter to method .of() to get instance in AlarmsRecyclerAdapter class.

          – Michael
          Mar 28 at 20:06






          Ye, you're right. But i cant get instance of ViewModel to use database like this mAlarmViewModel.insert(current). In Fragment class i can get instance in this way mAlarmViewModel = ViewModelProviders.of(this)[AlarmViewModel::class.java] but I need to pass some parameter to method .of() to get instance in AlarmsRecyclerAdapter class.

          – Michael
          Mar 28 at 20:06














          Like I said, you could just move the data modification to your Fragment, there you would have everything you need. If you really need to get the ViewModel inside your Recyclerview, just pass your Fragment as additional Argument in the constructor and use this reference, to get you ViewModel.

          – glm9637
          Mar 28 at 20:09





          Like I said, you could just move the data modification to your Fragment, there you would have everything you need. If you really need to get the ViewModel inside your Recyclerview, just pass your Fragment as additional Argument in the constructor and use this reference, to get you ViewModel.

          – glm9637
          Mar 28 at 20:09













          thanks a lot! Could you please explain me in which way i can move data modification to Fragment? I need my data be modified when switcher clicked and i can handle it only in AlarmsRecyclerAdapter class. Am I wrong?

          – Michael
          Mar 28 at 20:21






          thanks a lot! Could you please explain me in which way i can move data modification to Fragment? I need my data be modified when switcher clicked and i can handle it only in AlarmsRecyclerAdapter class. Am I wrong?

          – Michael
          Mar 28 at 20:21





















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405112%2funable-to-get-viewmodel-instance-in-recyclerview-adapter-class-kotlin%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해