Change customView of Tab when selected










0















enter image description hereI want to change image of tab Price when selected.
When it is pressed first time, it displays products according to price in ascending order ,when same tab is pressed again It displays products according to price in descending Order.
I am unable to change image of tab to display the order.
I am using customView for my 3rd tab as it contains image aligned right to text,



Below is my code:



price_tab.xml:



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/price"
android:textAllCaps="true"
android:textColor="@android:color/black" />

<ImageView
android:id="@+id/icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/lth" />

</LinearLayout>


ProductActivity.java



tablayout.addTab(tablayout.newTab().setText(getText(R.string.popular)), 0);
tablayout.addTab(tablayout.newTab().setText(getText(R.string.new_tag)), 1);
tablayout.addTab(tablayout.newTab().setText(getText(R.string.price)), 2);
View mCustomView = LayoutInflater.from(ProductActivity.this).inflate(R.layout.price_tab, null);
mImageViewCustom = (ImageView) mCustomView.findViewById(R.id.icon);
tablayout.getTabAt(2).setCustomView(mCustomView);
tablayout.addOnTabSelectedListener(new OnTabSelectedListener()
@Override
public void onTabSelected(Tab tab)

if (tab.getText().equals(getString(R.string.new_tag)))
sort = 0;
page = 1;
isLastPage = false;
productList.clear();
productListAdapter.notifyDataSetChanged();
getProducts();


else if (tab.getText().equals(getString(R.string.price)))
if (sort != 2)
sort = 2;

mImageViewCustom.setImageResource(R.drawable.lth);
else
sort = 3;
mImageViewCustom.setImageResource(R.drawable.htl);

page = 1;
isLastPage = false;
productList.clear();
productListAdapter.notifyDataSetChanged();
getProducts();

else if (tab.getText().equals(getString(R.string.popular)))
sort = 1;


page = 1;
isLastPage = false;
productList.clear();
productListAdapter.notifyDataSetChanged();
getProducts();




@Override
public void onTabUnselected(Tab tab)



@Override
public void onTabReselected(Tab tab)

if (tab.getText().equals("Price"))
if (sort == 2)
sort = 3;
else
sort = 2;
page = 1;
isLastPage = false;
productList.clear();
productListAdapter.notifyDataSetChanged();

getProducts();




);

getProducts();


enter image description here










share|improve this question




























    0















    enter image description hereI want to change image of tab Price when selected.
    When it is pressed first time, it displays products according to price in ascending order ,when same tab is pressed again It displays products according to price in descending Order.
    I am unable to change image of tab to display the order.
    I am using customView for my 3rd tab as it contains image aligned right to text,



    Below is my code:



    price_tab.xml:



    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/price"
    android:textAllCaps="true"
    android:textColor="@android:color/black" />

    <ImageView
    android:id="@+id/icon"
    android:layout_width="24dp"
    android:layout_height="24dp"
    android:src="@drawable/lth" />

    </LinearLayout>


    ProductActivity.java



    tablayout.addTab(tablayout.newTab().setText(getText(R.string.popular)), 0);
    tablayout.addTab(tablayout.newTab().setText(getText(R.string.new_tag)), 1);
    tablayout.addTab(tablayout.newTab().setText(getText(R.string.price)), 2);
    View mCustomView = LayoutInflater.from(ProductActivity.this).inflate(R.layout.price_tab, null);
    mImageViewCustom = (ImageView) mCustomView.findViewById(R.id.icon);
    tablayout.getTabAt(2).setCustomView(mCustomView);
    tablayout.addOnTabSelectedListener(new OnTabSelectedListener()
    @Override
    public void onTabSelected(Tab tab)

    if (tab.getText().equals(getString(R.string.new_tag)))
    sort = 0;
    page = 1;
    isLastPage = false;
    productList.clear();
    productListAdapter.notifyDataSetChanged();
    getProducts();


    else if (tab.getText().equals(getString(R.string.price)))
    if (sort != 2)
    sort = 2;

    mImageViewCustom.setImageResource(R.drawable.lth);
    else
    sort = 3;
    mImageViewCustom.setImageResource(R.drawable.htl);

    page = 1;
    isLastPage = false;
    productList.clear();
    productListAdapter.notifyDataSetChanged();
    getProducts();

    else if (tab.getText().equals(getString(R.string.popular)))
    sort = 1;


    page = 1;
    isLastPage = false;
    productList.clear();
    productListAdapter.notifyDataSetChanged();
    getProducts();




    @Override
    public void onTabUnselected(Tab tab)



    @Override
    public void onTabReselected(Tab tab)

    if (tab.getText().equals("Price"))
    if (sort == 2)
    sort = 3;
    else
    sort = 2;
    page = 1;
    isLastPage = false;
    productList.clear();
    productListAdapter.notifyDataSetChanged();

    getProducts();




    );

    getProducts();


    enter image description here










    share|improve this question


























      0












      0








      0








      enter image description hereI want to change image of tab Price when selected.
      When it is pressed first time, it displays products according to price in ascending order ,when same tab is pressed again It displays products according to price in descending Order.
      I am unable to change image of tab to display the order.
      I am using customView for my 3rd tab as it contains image aligned right to text,



      Below is my code:



      price_tab.xml:



      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:orientation="horizontal">

      <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/price"
      android:textAllCaps="true"
      android:textColor="@android:color/black" />

      <ImageView
      android:id="@+id/icon"
      android:layout_width="24dp"
      android:layout_height="24dp"
      android:src="@drawable/lth" />

      </LinearLayout>


      ProductActivity.java



      tablayout.addTab(tablayout.newTab().setText(getText(R.string.popular)), 0);
      tablayout.addTab(tablayout.newTab().setText(getText(R.string.new_tag)), 1);
      tablayout.addTab(tablayout.newTab().setText(getText(R.string.price)), 2);
      View mCustomView = LayoutInflater.from(ProductActivity.this).inflate(R.layout.price_tab, null);
      mImageViewCustom = (ImageView) mCustomView.findViewById(R.id.icon);
      tablayout.getTabAt(2).setCustomView(mCustomView);
      tablayout.addOnTabSelectedListener(new OnTabSelectedListener()
      @Override
      public void onTabSelected(Tab tab)

      if (tab.getText().equals(getString(R.string.new_tag)))
      sort = 0;
      page = 1;
      isLastPage = false;
      productList.clear();
      productListAdapter.notifyDataSetChanged();
      getProducts();


      else if (tab.getText().equals(getString(R.string.price)))
      if (sort != 2)
      sort = 2;

      mImageViewCustom.setImageResource(R.drawable.lth);
      else
      sort = 3;
      mImageViewCustom.setImageResource(R.drawable.htl);

      page = 1;
      isLastPage = false;
      productList.clear();
      productListAdapter.notifyDataSetChanged();
      getProducts();

      else if (tab.getText().equals(getString(R.string.popular)))
      sort = 1;


      page = 1;
      isLastPage = false;
      productList.clear();
      productListAdapter.notifyDataSetChanged();
      getProducts();




      @Override
      public void onTabUnselected(Tab tab)



      @Override
      public void onTabReselected(Tab tab)

      if (tab.getText().equals("Price"))
      if (sort == 2)
      sort = 3;
      else
      sort = 2;
      page = 1;
      isLastPage = false;
      productList.clear();
      productListAdapter.notifyDataSetChanged();

      getProducts();




      );

      getProducts();


      enter image description here










      share|improve this question
















      enter image description hereI want to change image of tab Price when selected.
      When it is pressed first time, it displays products according to price in ascending order ,when same tab is pressed again It displays products according to price in descending Order.
      I am unable to change image of tab to display the order.
      I am using customView for my 3rd tab as it contains image aligned right to text,



      Below is my code:



      price_tab.xml:



      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:orientation="horizontal">

      <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/price"
      android:textAllCaps="true"
      android:textColor="@android:color/black" />

      <ImageView
      android:id="@+id/icon"
      android:layout_width="24dp"
      android:layout_height="24dp"
      android:src="@drawable/lth" />

      </LinearLayout>


      ProductActivity.java



      tablayout.addTab(tablayout.newTab().setText(getText(R.string.popular)), 0);
      tablayout.addTab(tablayout.newTab().setText(getText(R.string.new_tag)), 1);
      tablayout.addTab(tablayout.newTab().setText(getText(R.string.price)), 2);
      View mCustomView = LayoutInflater.from(ProductActivity.this).inflate(R.layout.price_tab, null);
      mImageViewCustom = (ImageView) mCustomView.findViewById(R.id.icon);
      tablayout.getTabAt(2).setCustomView(mCustomView);
      tablayout.addOnTabSelectedListener(new OnTabSelectedListener()
      @Override
      public void onTabSelected(Tab tab)

      if (tab.getText().equals(getString(R.string.new_tag)))
      sort = 0;
      page = 1;
      isLastPage = false;
      productList.clear();
      productListAdapter.notifyDataSetChanged();
      getProducts();


      else if (tab.getText().equals(getString(R.string.price)))
      if (sort != 2)
      sort = 2;

      mImageViewCustom.setImageResource(R.drawable.lth);
      else
      sort = 3;
      mImageViewCustom.setImageResource(R.drawable.htl);

      page = 1;
      isLastPage = false;
      productList.clear();
      productListAdapter.notifyDataSetChanged();
      getProducts();

      else if (tab.getText().equals(getString(R.string.popular)))
      sort = 1;


      page = 1;
      isLastPage = false;
      productList.clear();
      productListAdapter.notifyDataSetChanged();
      getProducts();




      @Override
      public void onTabUnselected(Tab tab)



      @Override
      public void onTabReselected(Tab tab)

      if (tab.getText().equals("Price"))
      if (sort == 2)
      sort = 3;
      else
      sort = 2;
      page = 1;
      isLastPage = false;
      productList.clear();
      productListAdapter.notifyDataSetChanged();

      getProducts();




      );

      getProducts();


      enter image description here







      android android-custom-view android-tablayout






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 '18 at 3:50









      Ayush Khare

      1,1581720




      1,1581720










      asked Nov 15 '18 at 3:13









      user3792429user3792429

      969




      969






















          3 Answers
          3






          active

          oldest

          votes


















          2














          In your onTabReselcted(), try below code:



          @Override
          public void onTabReselected(TabLayout.Tab tab)
          if (tab.getText().toString().equals("Price"))
          if (sort == 2)
          sort = 3;
          else
          sort = 2;
          page = 1;
          isLastPage = false;
          productList.clear();
          productListAdapter.notifyDataSetChanged();

          //change tab icon
          View view = tab.getCustomView();
          if (view != null)
          ImageView icon = view.findViewById(R.id.icon);
          icon.setImageResource(R.drawable.your_image_resource);


          getProducts();




          Depending on your sort logic you can change the icon from increasing to decreasing and vice versa






          share|improve this answer























          • It worked,thanks!

            – user3792429
            Nov 15 '18 at 6:08


















          1














          By using this you can customize any tab you want according to the current position of the tab.



          private TabLayout tabs;
          tabs = view.findViewById(R.id.tabs);


          .



           tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener()

          @Override
          public void onTabSelected(TabLayout.Tab tab)


          if (tab.getPosition()==your tab position)
          tabs.setTabTextColors(Color.parseColor("#fdb827"), Color.parseColor("#ffffff"));
          tabs.setSelectedTabIndicatorColor(Color.parseColor("#ffffff"));

          else
          tabs.setTabTextColors(Color.parseColor("#fdb827"), Color.parseColor("#F57F17"));
          tabs.setSelectedTabIndicatorColor(Color.parseColor("#fdb827"));






          @Override
          public void onTabUnselected(TabLayout.Tab tab)


          @Override
          public void onTabReselected(TabLayout.Tab tab)


          );


          Hope this helps.






          share|improve this answer























          • I want to change the tab Image which is next to Price Text.When Price Tab is pressed,image next to it shoud toggle from increasing to decreasing or decreasing to increasing

            – user3792429
            Nov 15 '18 at 5:36


















          0














          Change tab.getText() to tab.getText().toString()






          share|improve this answer























          • I tried, it didnt work! I am able to display products according to price.Problem is only with the tab image.When price tab is pressed,the image should toggle from increasing -decreasing

            – user3792429
            Nov 15 '18 at 5:30











          • Try to log the values when clicked

            – Athira
            Nov 15 '18 at 5:44










          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/3.0/"u003ecc by-sa 3.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%2f53311874%2fchange-customview-of-tab-when-selected%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          In your onTabReselcted(), try below code:



          @Override
          public void onTabReselected(TabLayout.Tab tab)
          if (tab.getText().toString().equals("Price"))
          if (sort == 2)
          sort = 3;
          else
          sort = 2;
          page = 1;
          isLastPage = false;
          productList.clear();
          productListAdapter.notifyDataSetChanged();

          //change tab icon
          View view = tab.getCustomView();
          if (view != null)
          ImageView icon = view.findViewById(R.id.icon);
          icon.setImageResource(R.drawable.your_image_resource);


          getProducts();




          Depending on your sort logic you can change the icon from increasing to decreasing and vice versa






          share|improve this answer























          • It worked,thanks!

            – user3792429
            Nov 15 '18 at 6:08















          2














          In your onTabReselcted(), try below code:



          @Override
          public void onTabReselected(TabLayout.Tab tab)
          if (tab.getText().toString().equals("Price"))
          if (sort == 2)
          sort = 3;
          else
          sort = 2;
          page = 1;
          isLastPage = false;
          productList.clear();
          productListAdapter.notifyDataSetChanged();

          //change tab icon
          View view = tab.getCustomView();
          if (view != null)
          ImageView icon = view.findViewById(R.id.icon);
          icon.setImageResource(R.drawable.your_image_resource);


          getProducts();




          Depending on your sort logic you can change the icon from increasing to decreasing and vice versa






          share|improve this answer























          • It worked,thanks!

            – user3792429
            Nov 15 '18 at 6:08













          2












          2








          2







          In your onTabReselcted(), try below code:



          @Override
          public void onTabReselected(TabLayout.Tab tab)
          if (tab.getText().toString().equals("Price"))
          if (sort == 2)
          sort = 3;
          else
          sort = 2;
          page = 1;
          isLastPage = false;
          productList.clear();
          productListAdapter.notifyDataSetChanged();

          //change tab icon
          View view = tab.getCustomView();
          if (view != null)
          ImageView icon = view.findViewById(R.id.icon);
          icon.setImageResource(R.drawable.your_image_resource);


          getProducts();




          Depending on your sort logic you can change the icon from increasing to decreasing and vice versa






          share|improve this answer













          In your onTabReselcted(), try below code:



          @Override
          public void onTabReselected(TabLayout.Tab tab)
          if (tab.getText().toString().equals("Price"))
          if (sort == 2)
          sort = 3;
          else
          sort = 2;
          page = 1;
          isLastPage = false;
          productList.clear();
          productListAdapter.notifyDataSetChanged();

          //change tab icon
          View view = tab.getCustomView();
          if (view != null)
          ImageView icon = view.findViewById(R.id.icon);
          icon.setImageResource(R.drawable.your_image_resource);


          getProducts();




          Depending on your sort logic you can change the icon from increasing to decreasing and vice versa







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 '18 at 5:54









          Ayush KhareAyush Khare

          1,1581720




          1,1581720












          • It worked,thanks!

            – user3792429
            Nov 15 '18 at 6:08

















          • It worked,thanks!

            – user3792429
            Nov 15 '18 at 6:08
















          It worked,thanks!

          – user3792429
          Nov 15 '18 at 6:08





          It worked,thanks!

          – user3792429
          Nov 15 '18 at 6:08













          1














          By using this you can customize any tab you want according to the current position of the tab.



          private TabLayout tabs;
          tabs = view.findViewById(R.id.tabs);


          .



           tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener()

          @Override
          public void onTabSelected(TabLayout.Tab tab)


          if (tab.getPosition()==your tab position)
          tabs.setTabTextColors(Color.parseColor("#fdb827"), Color.parseColor("#ffffff"));
          tabs.setSelectedTabIndicatorColor(Color.parseColor("#ffffff"));

          else
          tabs.setTabTextColors(Color.parseColor("#fdb827"), Color.parseColor("#F57F17"));
          tabs.setSelectedTabIndicatorColor(Color.parseColor("#fdb827"));






          @Override
          public void onTabUnselected(TabLayout.Tab tab)


          @Override
          public void onTabReselected(TabLayout.Tab tab)


          );


          Hope this helps.






          share|improve this answer























          • I want to change the tab Image which is next to Price Text.When Price Tab is pressed,image next to it shoud toggle from increasing to decreasing or decreasing to increasing

            – user3792429
            Nov 15 '18 at 5:36















          1














          By using this you can customize any tab you want according to the current position of the tab.



          private TabLayout tabs;
          tabs = view.findViewById(R.id.tabs);


          .



           tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener()

          @Override
          public void onTabSelected(TabLayout.Tab tab)


          if (tab.getPosition()==your tab position)
          tabs.setTabTextColors(Color.parseColor("#fdb827"), Color.parseColor("#ffffff"));
          tabs.setSelectedTabIndicatorColor(Color.parseColor("#ffffff"));

          else
          tabs.setTabTextColors(Color.parseColor("#fdb827"), Color.parseColor("#F57F17"));
          tabs.setSelectedTabIndicatorColor(Color.parseColor("#fdb827"));






          @Override
          public void onTabUnselected(TabLayout.Tab tab)


          @Override
          public void onTabReselected(TabLayout.Tab tab)


          );


          Hope this helps.






          share|improve this answer























          • I want to change the tab Image which is next to Price Text.When Price Tab is pressed,image next to it shoud toggle from increasing to decreasing or decreasing to increasing

            – user3792429
            Nov 15 '18 at 5:36













          1












          1








          1







          By using this you can customize any tab you want according to the current position of the tab.



          private TabLayout tabs;
          tabs = view.findViewById(R.id.tabs);


          .



           tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener()

          @Override
          public void onTabSelected(TabLayout.Tab tab)


          if (tab.getPosition()==your tab position)
          tabs.setTabTextColors(Color.parseColor("#fdb827"), Color.parseColor("#ffffff"));
          tabs.setSelectedTabIndicatorColor(Color.parseColor("#ffffff"));

          else
          tabs.setTabTextColors(Color.parseColor("#fdb827"), Color.parseColor("#F57F17"));
          tabs.setSelectedTabIndicatorColor(Color.parseColor("#fdb827"));






          @Override
          public void onTabUnselected(TabLayout.Tab tab)


          @Override
          public void onTabReselected(TabLayout.Tab tab)


          );


          Hope this helps.






          share|improve this answer













          By using this you can customize any tab you want according to the current position of the tab.



          private TabLayout tabs;
          tabs = view.findViewById(R.id.tabs);


          .



           tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener()

          @Override
          public void onTabSelected(TabLayout.Tab tab)


          if (tab.getPosition()==your tab position)
          tabs.setTabTextColors(Color.parseColor("#fdb827"), Color.parseColor("#ffffff"));
          tabs.setSelectedTabIndicatorColor(Color.parseColor("#ffffff"));

          else
          tabs.setTabTextColors(Color.parseColor("#fdb827"), Color.parseColor("#F57F17"));
          tabs.setSelectedTabIndicatorColor(Color.parseColor("#fdb827"));






          @Override
          public void onTabUnselected(TabLayout.Tab tab)


          @Override
          public void onTabReselected(TabLayout.Tab tab)


          );


          Hope this helps.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 '18 at 4:09









          nimi0112nimi0112

          9461722




          9461722












          • I want to change the tab Image which is next to Price Text.When Price Tab is pressed,image next to it shoud toggle from increasing to decreasing or decreasing to increasing

            – user3792429
            Nov 15 '18 at 5:36

















          • I want to change the tab Image which is next to Price Text.When Price Tab is pressed,image next to it shoud toggle from increasing to decreasing or decreasing to increasing

            – user3792429
            Nov 15 '18 at 5:36
















          I want to change the tab Image which is next to Price Text.When Price Tab is pressed,image next to it shoud toggle from increasing to decreasing or decreasing to increasing

          – user3792429
          Nov 15 '18 at 5:36





          I want to change the tab Image which is next to Price Text.When Price Tab is pressed,image next to it shoud toggle from increasing to decreasing or decreasing to increasing

          – user3792429
          Nov 15 '18 at 5:36











          0














          Change tab.getText() to tab.getText().toString()






          share|improve this answer























          • I tried, it didnt work! I am able to display products according to price.Problem is only with the tab image.When price tab is pressed,the image should toggle from increasing -decreasing

            – user3792429
            Nov 15 '18 at 5:30











          • Try to log the values when clicked

            – Athira
            Nov 15 '18 at 5:44















          0














          Change tab.getText() to tab.getText().toString()






          share|improve this answer























          • I tried, it didnt work! I am able to display products according to price.Problem is only with the tab image.When price tab is pressed,the image should toggle from increasing -decreasing

            – user3792429
            Nov 15 '18 at 5:30











          • Try to log the values when clicked

            – Athira
            Nov 15 '18 at 5:44













          0












          0








          0







          Change tab.getText() to tab.getText().toString()






          share|improve this answer













          Change tab.getText() to tab.getText().toString()







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 '18 at 4:06









          AthiraAthira

          476118




          476118












          • I tried, it didnt work! I am able to display products according to price.Problem is only with the tab image.When price tab is pressed,the image should toggle from increasing -decreasing

            – user3792429
            Nov 15 '18 at 5:30











          • Try to log the values when clicked

            – Athira
            Nov 15 '18 at 5:44

















          • I tried, it didnt work! I am able to display products according to price.Problem is only with the tab image.When price tab is pressed,the image should toggle from increasing -decreasing

            – user3792429
            Nov 15 '18 at 5:30











          • Try to log the values when clicked

            – Athira
            Nov 15 '18 at 5:44
















          I tried, it didnt work! I am able to display products according to price.Problem is only with the tab image.When price tab is pressed,the image should toggle from increasing -decreasing

          – user3792429
          Nov 15 '18 at 5:30





          I tried, it didnt work! I am able to display products according to price.Problem is only with the tab image.When price tab is pressed,the image should toggle from increasing -decreasing

          – user3792429
          Nov 15 '18 at 5:30













          Try to log the values when clicked

          – Athira
          Nov 15 '18 at 5:44





          Try to log the values when clicked

          – Athira
          Nov 15 '18 at 5:44

















          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%2f53311874%2fchange-customview-of-tab-when-selected%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







          這個網誌中的熱門文章

          Barbados

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3