-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f42f59
commit d1c3f2d
Showing
87 changed files
with
517 additions
and
218 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
app/src/main/kotlin/com/d4rk/androidtutorials/ui/android/alertdialog/AlertDialogActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.d4rk.androidtutorials.ui.android.alertdialog | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.d4rk.androidtutorials.R | ||
import com.d4rk.androidtutorials.databinding.ActivityAlertDialogBinding | ||
class AlertDialogActivity : AppCompatActivity() { | ||
private lateinit var binding : ActivityAlertDialogBinding | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivityAlertDialogBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
binding.button.setOnClickListener { | ||
val alertDialog: AlertDialog.Builder = AlertDialog.Builder(this) | ||
alertDialog.setTitle(R.string.alert_dialog_title) | ||
alertDialog.setMessage(R.string.alert_dialog_message) | ||
alertDialog.create() | ||
alertDialog.setPositiveButton(R.string.alert_dialog_button_positive, null) | ||
alertDialog.setNegativeButton(R.string.alert_dialog_button_negative, null) | ||
alertDialog.show() | ||
} | ||
binding.showButtonCodeSyntax.setOnClickListener { | ||
val intent = Intent(this, AlertDialogCodeActivity::class.java) | ||
startActivity(intent) | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...c/main/kotlin/com/d4rk/androidtutorials/ui/android/alertdialog/AlertDialogCodeActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
@file:Suppress("DEPRECATION") | ||
package com.d4rk.androidtutorials.ui.android.alertdialog | ||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.FragmentManager | ||
import androidx.fragment.app.FragmentPagerAdapter | ||
import androidx.viewpager.widget.ViewPager | ||
import com.d4rk.androidtutorials.R | ||
import com.d4rk.androidtutorials.ui.android.alertdialog.tabs.AlertDialogTabCodeFragment | ||
import com.d4rk.androidtutorials.ui.android.alertdialog.tabs.AlertDialogTabLayoutFragment | ||
import com.google.android.material.tabs.TabLayout | ||
class AlertDialogCodeActivity: AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_tab_layout) | ||
val tabs : TabLayout = findViewById(R.id.tabs) | ||
val viewpager : ViewPager = findViewById(R.id.viewpager) | ||
setupViewPager(viewpager) | ||
tabs.setupWithViewPager(viewpager) | ||
} | ||
private fun setupViewPager(viewPager: ViewPager) { | ||
val adapter = ViewPagerAdapter(supportFragmentManager) | ||
adapter.addFragment(AlertDialogTabCodeFragment(), getString(R.string.code_kotlin)) | ||
adapter.addFragment(AlertDialogTabLayoutFragment(), getString(R.string.layout_xml)) | ||
viewPager.adapter = adapter | ||
} | ||
internal inner class ViewPagerAdapter(manager: FragmentManager) : FragmentPagerAdapter(manager) { | ||
private val mFragmentList = ArrayList<Fragment>() | ||
private val mFragmentTitleList = ArrayList<String>() | ||
override fun getItem(position: Int): Fragment { | ||
return mFragmentList[position] | ||
} | ||
override fun getCount(): Int { | ||
return mFragmentList.size | ||
} | ||
fun addFragment(fragment: Fragment, title: String) { | ||
mFragmentList.add(fragment) | ||
mFragmentTitleList.add(title) | ||
} | ||
override fun getPageTitle(position: Int): CharSequence { | ||
return mFragmentTitleList[position] | ||
} | ||
} | ||
} |
Oops, something went wrong.