{"action":"created","issue":{"url":"https://api.github.com/repos/ogaclejapan/SmartTabLayout/issues/79","labels_url":"https://api.github.com/repos/ogaclejapan/SmartTabLayout/issues/79/labels{/name}","comments_url":"https://api.github.com/repos/ogaclejapan/SmartTabLayout/issues/79/comments","events_url":"https://api.github.com/repos/ogaclejapan/SmartTabLayout/issues/79/events","html_url":"https://github.com/ogaclejapan/SmartTabLayout/issues/79","id":110478919,"number":79,"title":"Issue using custom_tab_icon with my code","user":{"login":"a-random-package","id":3674318,"avatar_url":"https://avatars.githubusercontent.com/u/3674318?v=3","gravatar_id":"","url":"https://api.github.com/users/a-random-package","html_url":"https://github.com/a-random-package","followers_url":"https://api.github.com/users/a-random-package/followers","following_url":"https://api.github.com/users/a-random-package/following{/other_user}","gists_url":"https://api.github.com/users/a-random-package/gists{/gist_id}","starred_url":"https://api.github.com/users/a-random-package/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/a-random-package/subscriptions","organizations_url":"https://api.github.com/users/a-random-package/orgs","repos_url":"https://api.github.com/users/a-random-package/repos","events_url":"https://api.github.com/users/a-random-package/events{/privacy}","received_events_url":"https://api.github.com/users/a-random-package/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-08T15:42:52Z","updated_at":"2015-11-21T14:26:22Z","closed_at":"2015-11-21T14:26:22Z","body":"Okay, so, it's not MY code. Long story short, the developer I was working with up and decided if I wanted any further updates or help I would have to pay. (He was kind enough to direct me to this library though)\r\n\r\nI can get everything working until the custom java comes in. I'm not a developer, more front-end but I'm a designer first and foremost. I dug through all issues and found one that looked hopeful for me here: https://github.com/ogaclejapan/SmartTabLayout/issues/34\r\n\r\nHere is how I tried to implement it:\r\n\r\n    package com.arandompackage.banded.fragment;\r\n\r\n    import android.app.SearchManager;\r\n    import android.content.Context;\r\n    import android.content.res.Resources;\r\n    import android.graphics.Color;\r\n    import android.os.Bundle;\r\n    import android.support.v4.app.Fragment;\r\n    import android.support.v4.view.PagerAdapter;\r\n    import android.support.v4.view.ViewPager;\r\n    import android.support.v7.widget.SearchView;\r\n    import android.util.Log;\r\n    import android.view.LayoutInflater;\r\n    import android.view.Menu;\r\n    import android.view.MenuInflater;\r\n    import android.view.MenuItem;\r\n    import android.view.View;\r\n    import android.view.ViewGroup;\r\n    import android.view.inputmethod.InputMethodManager;\r\n    import android.widget.ImageView;\r\n    import android.widget.ProgressBar;\r\n\r\n    import com.google.analytics.tracking.android.Fields;\r\n    import com.google.analytics.tracking.android.MapBuilder;\r\n\r\n    import com.arandompackage.banded.R;\r\n    import com.arandompackage.banded.ThemeApp;\r\n    import com.arandompackage.banded.fragment.adapters.IconsFragmentAdapter;\r\n    import com.arandompackage.banded.fragment.icons.IconBoolean;\r\n\r\n    import com.arandompackage.banded.util.ApplyTheme;\r\n    import com.ogaclejapan.smarttablayout.SmartTabLayout;\r\n\r\n    public class IconsFrag extends Fragment {\r\n\r\n    public static final String FRAG_TAG = \"icons\";\r\n\r\n    private ViewPager mViewPager;\r\n\r\n\r\n    private IconsFragmentAdapter mSectionsPagerAdapter;\r\n    private ProgressBar progressBar;\r\n\r\n    @Override\r\n    public void onCreate(Bundle savedInstanceState) {\r\n        Log.i(FRAG_TAG, \"onCreate\");\r\n        super.onCreate(savedInstanceState);\r\n\r\n        setHasOptionsMenu(true);\r\n        setRetainInstance(true);\r\n    }\r\n\r\n    final LayoutInflater inflater = LayoutInflater.from(this);\r\n    final Resources res = getResources();\r\n\r\n    @Override\r\n    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){\r\n        Log.i(FRAG_TAG, \"onCreateView\");\r\n        View view = inflater.inflate(R.layout.custom_tab_icon, container, false);\r\n        ImageView icon = (ImageView) View.findViewById(R.id.custom_tab_icon);\r\n        switch (position) {\r\n            case 0:\r\n                icon.setImageDrawable(res.getDrawable(R.drawable.ic_exit_to_app_24dp));\r\n                break;\r\n            case 1:\r\n                icon.setImageDrawable(res.getDrawable(R.drawable.ic_crop_original_24dp));\r\n                break;\r\n            case 2:\r\n                icon.setImageDrawable(res.getDrawable(R.drawable.ic_exit_to_app_24dp));\r\n                break;\r\n            case 3:\r\n                icon.setImageDrawable(res.getDrawable(R.drawable.ic_exit_to_app_24dp));\r\n                break;\r\n            case 4:\r\n                icon.setImageDrawable(res.getDrawable(R.drawable.ic_exit_to_app_24dp));\r\n                break;\r\n            case 5:\r\n                icon.setImageDrawable(res.getDrawable(R.drawable.ic_exit_to_app_24dp));\r\n                break;\r\n            default:\r\n                throw new IllegalStateException(\"Invalid position: \" + position);\r\n        }\r\n\r\n        if (view != null) {\r\n            Log.i(FRAG_TAG, \"view != null\");\r\n            mViewPager = (ViewPager) view.findViewById(R.id.viewpager);\r\n\r\n            mViewPager.setAdapter(new IconsFragmentAdapter(getChildFragmentManager(), getActivity()));\r\n\r\n\r\n            SmartTabLayout viewPagerTab = (SmartTabLayout) view.findViewById(R.id.viewpagertab);\r\n            viewPagerTab.setViewPager(mViewPager);\r\n\r\n            progressBar = (ProgressBar) getActivity().findViewById(R.id.base_progressSpinner);\r\n            progressBar.setVisibility(View.VISIBLE);\r\n        }\r\n        return view;\r\n    }\r\n\r\n\r\n\r\n    @Override\r\n    public void onStart() {\r\n        Log.i(FRAG_TAG, \"onStart\");\r\n        super.onStart();\r\n        ThemeApp.getGaTracker().send(MapBuilder.createAppView().set(Fields.SCREEN_NAME, FRAG_TAG).build());\r\n    }\r\n\r\n    @Override\r\n    public void onResume() {\r\n        Log.i(FRAG_TAG, \"onResume\");\r\n        super.onResume();\r\n\r\n        if (IconBoolean.getValue()){\r\n            mViewPager.setAdapter(new IconsFragmentAdapter(getChildFragmentManager(), getActivity()));\r\n\r\n            IconBoolean.setValue(false);\r\n        }\r\n    }\r\n\r\n    @Override\r\n    public void onPrepareOptionsMenu (Menu menu) {\r\n        Log.i(FRAG_TAG, \"onPrepareOptionsMenu\");\r\n        MenuInflater inflater = getActivity().getMenuInflater();\r\n        inflater.inflate(R.menu.icon_menu, menu);\r\n        MenuItem searchItem = menu.findItem(R.id.search);\r\n\r\n        SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);\r\n\r\n        SearchView searchView = (SearchView) searchItem.getActionView();\r\n        SearchView.SearchAutoComplete autoCompleteTextView = (SearchView.SearchAutoComplete) searchView.findViewById(R.id.search_src_text);\r\n\r\n        if (autoCompleteTextView != null) {\r\n            int theme = ApplyTheme.getTheme(getActivity());\r\n            if (theme == 0) {\r\n                autoCompleteTextView.setDropDownBackgroundDrawable(getResources().getDrawable(R.drawable.app_menu_dropdown_panel_holo_light));\r\n            } else {\r\n                autoCompleteTextView.setDropDownBackgroundDrawable(getResources().getDrawable(R.drawable.app_menu_dropdown_panel_holo_dark));\r\n            }\r\n        }\r\n        searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));\r\n\r\n    }\r\n\r\n    @Override\r\n    public boolean onOptionsItemSelected(MenuItem item) {\r\n        Log.i(FRAG_TAG, \"onOptionsItemSelected\");\r\n        return super.onOptionsItemSelected(item);\r\n    }\r\n\r\n    @Override\r\n    public void onPause() {\r\n        super.onPause();\r\n        getActivity().invalidateOptionsMenu();\r\n        // hide the keyboard in order to avoid getTextBeforeCursor on inactive InputConnection\r\n        InputMethodManager inputMethodManager = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);\r\n        inputMethodManager.hideSoftInputFromWindow(getView().getWindowToken(), 0);\r\n    }\r\n}\r\nHere is my custom tab xml:\r\n\r\n    <?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n    <LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\">\r\n\r\n    <com.ogaclejapan.smarttablayout.demo.TintableImageView\r\n        android:id=\"@+id/custom_tab_icon\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_gravity=\"center_horizontal\"\r\n        android:scaleType=\"center\"\r\n        app:tint=\"@color/white\"\r\n        />\r\n\r\n</LinearLayout>\r\n\r\nI've also added the TintableImageView.java\r\n\r\nI'm getting errors with the \r\n    ImageView icon = (ImageView) View.findViewById(R.id.custom_tab_icon);\r\n\r\nIt says: non-static variable this cannot be referenced from a static context and also that 'position' cannot be resolved...\r\n\r\nI've gone to SO and looked over the dozens of questions regarding the errors and the best one is this one: http://stackoverflow.com/questions/2559527/non-static-variable-cannot-be-referenced-from-a-static-context?lq=1\r\n\r\nBut like I said, Im a designer and I can't interpret all of this to get it working. Any help would be very appreciated."},"comment":{"url":"https://api.github.com/repos/ogaclejapan/SmartTabLayout/issues/comments/158647759","html_url":"https://github.com/ogaclejapan/SmartTabLayout/issues/79#issuecomment-158647759","issue_url":"https://api.github.com/repos/ogaclejapan/SmartTabLayout/issues/79","id":158647759,"user":{"login":"ogaclejapan","id":1496485,"avatar_url":"https://avatars.githubusercontent.com/u/1496485?v=3","gravatar_id":"","url":"https://api.github.com/users/ogaclejapan","html_url":"https://github.com/ogaclejapan","followers_url":"https://api.github.com/users/ogaclejapan/followers","following_url":"https://api.github.com/users/ogaclejapan/following{/other_user}","gists_url":"https://api.github.com/users/ogaclejapan/gists{/gist_id}","starred_url":"https://api.github.com/users/ogaclejapan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ogaclejapan/subscriptions","organizations_url":"https://api.github.com/users/ogaclejapan/orgs","repos_url":"https://api.github.com/users/ogaclejapan/repos","events_url":"https://api.github.com/users/ogaclejapan/events{/privacy}","received_events_url":"https://api.github.com/users/ogaclejapan/received_events","type":"User","site_admin":false},"created_at":"2015-11-21T14:26:22Z","updated_at":"2015-11-21T14:26:22Z","body":"I am sorry for the late answer.\r\n\r\nI think this library is not the cause.\r\nBecause, I will close.\r\n"}}