File tree Expand file tree Collapse file tree 3 files changed +21
-13
lines changed
android-swipe-views-tabs/app/src/main Expand file tree Collapse file tree 3 files changed +21
-13
lines changed Original file line number Diff line number Diff line change 1
1
package com .hmkcode ;
2
2
3
3
import android .support .design .widget .TabLayout ;
4
- import android .support .v4 .app .FragmentActivity ;
5
4
import android .support .v4 .view .ViewPager ;
6
5
import android .os .Bundle ;
6
+ import android .support .v7 .app .AppCompatActivity ;
7
+
7
8
import com .hmkcode .adapters .MyFragmentPagerAdapter ;
8
9
9
- public class MainActivity extends FragmentActivity {
10
+ public class MainActivity extends AppCompatActivity {
10
11
11
12
MyFragmentPagerAdapter myFragmentPagerAdapter ;
12
13
ViewPager viewPager ;
13
14
TabLayout tabLayout ;
14
15
15
16
@ Override
16
17
protected void onCreate (Bundle savedInstanceState ) {
18
+
17
19
super .onCreate (savedInstanceState );
18
20
setContentView (R .layout .activity_main );
19
21
22
+
20
23
viewPager = (ViewPager ) findViewById (R .id .viewPager );
24
+ tabLayout = (TabLayout ) findViewById (R .id .tabLayout );
21
25
22
26
setPagerAdapter ();
23
27
setTabLayout ();
28
+
24
29
}
25
30
26
31
private void setPagerAdapter (){
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" utf-8" ?>
2
- <android .support.constraint.ConstraintLayout xmlns : android = " http://schemas.android.com/apk/res/android "
3
- xmlns : app =" http://schemas.android.com/apk/res-auto "
2
+ <android .support.constraint.ConstraintLayout
3
+ xmlns : android =" http://schemas.android.com/apk/res/android "
4
4
xmlns : tools =" http://schemas.android.com/tools"
5
+ xmlns : app =" http://schemas.android.com/apk/res-auto"
5
6
android : layout_width =" match_parent"
6
7
android : layout_height =" match_parent"
7
8
tools : context =" .MainActivity" >
15
16
<android .support.design.widget.TabLayout
16
17
android : id =" @+id/tabLayout"
17
18
android : layout_width =" match_parent"
18
- android : layout_height =" wrap_content" />
19
+ android : layout_height =" wrap_content"
20
+ app : tabMode =" fixed"
21
+ app : tabGravity =" fill" />
19
22
20
23
</android .support.constraint.ConstraintLayout>
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" utf-8" ?>
2
2
<android .support.constraint.ConstraintLayout
3
- xmlns : android =" http://schemas.android.com/apk/res/android"
4
- android : layout_width =" match_parent"
5
- android : layout_height =" match_parent" >
3
+ xmlns:android=" http://schemas.android.com/apk/res/android"
4
+ android:layout_width=" match_parent"
5
+ android:layout_height=" match_parent" >
6
6
7
- <TextView
8
- android : layout_width =" match_parent"
9
- android : layout_height =" match_parent"
10
- android : text =" Second Fragment"
11
- android : gravity =" center" />
7
+ <TextView
8
+ android : layout_width =" match_parent"
9
+ android : layout_height =" match_parent"
10
+ android : text =" Second Fragment"
11
+ android : gravity =" center" />
12
12
13
13
</android .support.constraint.ConstraintLayout>
You can’t perform that action at this time.
0 commit comments