android-tablayout

TabLayout with ViewPager not working inside fragment Android

a 夏天 提交于 2019-11-28 01:14:25
问题 Hi I have a TabLayout and ViewPager inside a fragment. But I can not slide beetween tab to come to child fragment (Working normally when in Activity but not work in fragment). Here is my code for Tablayout inside fragment: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View inflateView = inflater.inflate(R.layout.fragment_assign_beacon_to_event, container, false); //Viewpager and TabLayout viewPager = (ViewPager)inflateView

error can not resolve symbol TabLayout and 'design

被刻印的时光 ゝ 提交于 2019-11-28 01:09:47
Please help: I got error when import android.support.design.widget.TabLayout It say "can not resolve symbol 'design' My build.gradle: compileSdkVersion 26 buildToolsVersion "26.0.0" dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:26' compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.android.support:support-v4:26' testCompile 'junit:junit:4.12' } Nilesh Rathod

Android TabLayout inside Fragment

大兔子大兔子 提交于 2019-11-27 19:07:33
I am using Navigation Drawer to navigate between fragments they all use the MainActivity toolbar but each fragment has it's own TabLayout with 3 tabs and in each tab I am using RecyclerView to show different text and images. I did this last time using actvities instead of fragments but now using the drawer it's beter to use fragments. I have got to a point where the tabs work but as soon as I put the ViewPager in and connect the adapters to the tabs and I open the new fragment from the drawer I get a Null Pointer what could be the problem here? MainActivity.java public class MainActivity

How to select next tab from child fragment

雨燕双飞 提交于 2019-11-27 16:32:22
I need to switch next tab, when a button is clicked from a child fragment. This is how I setup tabs in parent, TabAdapter adapter; private void setUpTabs(ViewPager viewPager) { adapter = new TabAdapter(getSupportFragmentManager()); adapter.addFragment(new FirstTabFragment(), "First Tab"); adapter.addFragment(new SecondTabFragment(), "Second Tab"); viewPager.setAdapter(adapter); } And my TabAdapter class is, public class TabAdapter extends FragmentPagerAdapter { private final List<Fragment> mFragmentList = new ArrayList<>(); private final List<String> mFragmentTitleList = new ArrayList<>();

Android Studio cannot resolve symbol 'TabLayout'

眉间皱痕 提交于 2019-11-27 14:31:41
问题 Cannot resolve symbol TabLayout ? How to clear this error? Please help me. I already imported import android.support.design.widget.TabLayout; 回答1: Had a similar problem, to fix this in Android Studio (AS) I went Build->Clean Project and AS sorted everything out. Make sure in your build.gradle file under dependencies that you have: dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:your_api_version_number.0.0' compile 'com.android.support

Add Icons+Text to TabLayout

社会主义新天地 提交于 2019-11-27 11:30:35
I am working on a screen which contains Three tabs I am trying to add an icon with My text in tabs and i want the image to be upper the text and there should be some space between them it is my code. public class HomeScreen extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { private Toolbar toolbar; private ViewPager pager; private ViewPagerAdapter adapter; private SlidingTabLayout tabs; private CharSequence Titles[] = {"News", "Most Views", "Chart"}; int Numboftabs = 3; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate

How to set android TabLayout in the bottom of the screen?

試著忘記壹切 提交于 2019-11-27 11:22:49
My question is how I can set the new android material design TabLayout to be in the bottom of the screen, kind of like Instagram's bottom toolbar. If you have never seen Instagram's UI here is a screenshot of it : . If there is a better way of approaching this, please feel free to post it here (with a code example if possible), I will greatly appreciate it. Here is my code: activity_main.xml <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.v7.widget

TabLayout tab selection

扶醉桌前 提交于 2019-11-27 10:28:30
How to select tab in TabLayout programmatically? TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(viewPager); If you know the index of the tab you want to select, you can do it like so: TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); TabLayout.Tab tab = tabLayout.getTabAt(someIndex); tab.select(); This technique works even if you're using the TabLayout by itself without a ViewPager (which is atypical, and probably bad practice, but I've seen it done). This is how I solved it: void selectPage(int pageIndex){ tabLayout.setScrollPosition(pageIndex

Dynamically add and remove tabs in TabLayout(material design) android

梦想与她 提交于 2019-11-27 10:17:00
问题 I have a TabLayout and inside that I have ViewPager. I need to dynamically add and remove tab in tablayout(material design). I can able to add the tabs dynamically but while removing the tab, tab is removing correctly. But viewpager last item is deleted. So tab is not showing specific fragment. FYI i have used FragmentPagerAdapter. I have followed this tutorial to implement this https://androidbelieve.com/navigation-drawer-with-swipe-tabs-using-design-support-library public class TabFragment

How do I change the color of icon of the selected tab of TabLayout?

荒凉一梦 提交于 2019-11-27 09:34:51
问题 I'm using a TabLayout with a ViewPager and I'm wondering how I can most efficiently change the color of the icon of the selected tab in the TabLayout. A perfect reference for how this is implemented is Google's Youtube app . On the main page, there are four icons that are colored dark gray. When a specific tab is selected, the tab's icon becomes white. Without any third party libraries , how can I achieve the same effect? One possible solution is apparently with selectors. But in that case, I