-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainActivity.kt
66 lines (61 loc) · 2.4 KB
/
MainActivity.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.example.appiot
import android.content.Context
import android.content.SharedPreferences
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.*
import androidx.viewpager2.widget.ViewPager2
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.OnMapReadyCallback
import com.google.android.gms.maps.SupportMapFragment
import com.google.android.gms.maps.model.BitmapDescriptor
import com.google.android.gms.maps.model.BitmapDescriptorFactory
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.MarkerOptions
import com.google.android.material.tabs.TabLayoutMediator
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError
import com.google.firebase.database.ValueEventListener
import com.google.firebase.database.ktx.getValue
import java.sql.DriverManager.println
import java.util.*
import com.example.appiot.fragment.fragment1
import com.example.appiot.fragment.fragment2
import com.example.appiot.fragment.fragment3
import com.example.appiot.fragment.fragment4
class MainActivity : AppCompatActivity() {
lateinit var mapFragment: SupportMapFragment
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val b1= findViewById<Button>(R.id.fragment1btn)
val b2 = findViewById<Button>(R.id.fragment2btn)
val b3 = findViewById<Button>(R.id.fragment3btn)
val b4 = findViewById<Button>(R.id.fragment4btn)
b1.setOnClickListener {
replaceFragment(fragment1())
}
b2.setOnClickListener {
replaceFragment(fragment2())
}
b3.setOnClickListener{
replaceFragment(fragment3())
}
b4.setOnClickListener{
replaceFragment(fragment4())
}
}
private fun replaceFragment(fragment: Fragment){
val fragmentManager = supportFragmentManager
val fragmentTransaction = fragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.map1,fragment)
fragmentTransaction.commit()
}
}