android-tabs

How can i create dynamically tab with viewpager in android?

时光总嘲笑我的痴心妄想 提交于 2019-12-03 06:00:22
Explanation: Suppose, I have multiple categories which come from my REST. I don't know how many categories it's mat be 5,7 or sometimes 2 etc. I want to put all the categories on my tab with viewpager. I want to create a tab accordingly to the categories size. let's see e.g. suppose in my REST response have only 2 categories it's create only two tab. if it have 5 categories then 5 tab and so on. Here is the sample test example to create a tabs. MainActivity.java public class MainActivity extends AppCompatActivity { TabLayout tabLayout; ViewPager viewPager; Toolbar toolbar; @Override protected

Sliding Tabs in Toolbar using Material Design

烈酒焚心 提交于 2019-12-03 05:31:43
I have been learning to use Sliding Tabs using Material Design using this post . I have managed to achieve SlidingTabs below the Toolbar , like this one: But now i would like to create ActionBar/ToolBar Fragment Tabs ... I was able to recreate exactly what you are looking to implement. I am using the this Library for the tabs. This is the view I have created: Import Library Through Dependencies or Download Project and Import Manually compile 'com.jpardogo.materialtabstrip:library:1.0.9' styles.xml <resources> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name=

How to create app bar with icons using TabLayout Android Design?

筅森魡賤 提交于 2019-12-03 03:49:34
问题 I'm trying to use the new TabLayout in the android design library to create app bar with icons. public void setupTabLayout(TabLayout tabLayout) { tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER); tabLayout.setupWithViewPager(mViewpager); tabLayout.getTabAt(0).setIcon(R.drawable.ic_tabbar_library); tabLayout.getTabAt(1).setIcon(R.drawable.ic_tabbar_recents); tabLayout.getTabAt(2).setIcon(R.drawable.ic_tabbar_favorites); tabLayout.getTabAt(3)

Tab with icon using TabLayout in Android Design Library

房东的猫 提交于 2019-12-03 03:38:20
I'm trying to use the new TabLayout in the android design library to create app bar with icons only. like this: how can I do it using the new TabLayout Android Design Library. is there a simple solution for this, or i have to use the setCustomView only. i'm trying to avoid using it. because i didn't get the tint color for the icon like this image above. i try to write like this: tabLayout.addTab(tabLayout.newTab().setIcon(R.drawable.ic_dashboard)) but the icon still stay in the same color when i select the tab you have to create a selector for the icon. For example: <?xml version="1.0"

How to create app bar with icons using TabLayout Android Design?

旧街凉风 提交于 2019-12-02 18:07:06
I'm trying to use the new TabLayout in the android design library to create app bar with icons. public void setupTabLayout(TabLayout tabLayout) { tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER); tabLayout.setupWithViewPager(mViewpager); tabLayout.getTabAt(0).setIcon(R.drawable.ic_tabbar_library); tabLayout.getTabAt(1).setIcon(R.drawable.ic_tabbar_recents); tabLayout.getTabAt(2).setIcon(R.drawable.ic_tabbar_favorites); tabLayout.getTabAt(3).setIcon(R.drawable.ic_tabbar_notifications); tabLayout.getTabAt(4).setIcon(R.drawable.ic_tabbar_settings)

Pass data from one design tab to another tab

谁说胖子不能爱 提交于 2019-12-02 10:51:22
问题 I am using material design tabs as follows : Following is my MainActivity.class : public class MainActivity extends AppCompatActivity implements ViewPager.OnPageChangeListener { private TabLayout tabLayout; private ViewPager viewPager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tabLayout = (TabLayout) findViewById(R.id.tabs); viewPager = (ViewPager) findViewById(R.id.viewpager); ViewPagerAdapter

Tabs fragment fetch data every time I change tab

China☆狼群 提交于 2019-12-02 10:08:24
问题 activity_profile.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingTop="?android:attr/actionBarSize" android:background="@drawable/stalker_background" > <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:layout_width="match_parent" android:layout_height=

Pass data from one design tab to another tab

落花浮王杯 提交于 2019-12-02 04:51:20
I am using material design tabs as follows : Following is my MainActivity.class : public class MainActivity extends AppCompatActivity implements ViewPager.OnPageChangeListener { private TabLayout tabLayout; private ViewPager viewPager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tabLayout = (TabLayout) findViewById(R.id.tabs); viewPager = (ViewPager) findViewById(R.id.viewpager); ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(adapter); viewPager

Grid layout within tabs

做~自己de王妃 提交于 2019-12-02 03:20:51
I'm new to Android and therefore faced such problem. How can I change layout from: To: XML fragment_main: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.snbgearassistant.MainActivity$PlaceholderFragment"

Temporarily/Dynamically disable single page in Viewpager

旧街凉风 提交于 2019-12-02 00:09:12
问题 I have an extended FragmentPagerAdapter that provides 3 fragments to a ViewPager, giving me 3 pages that I can either swipe between or use the tabs I've added to the actionbar to manually choose a page. I'd like to temporarily disable the user from accessing the final page (a more generalized solution to disable any specific page would also be interesting, but not necessary) with either navigation type. I will then re-enable their access with a callback from one of the fragments. I've read