|
|
A sample library created using native Kotlin and XML, showing an activity that can be used as a separate feature on an app.
Step 1. Add the JitPack repository to your build file
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}Step 2. Add the dependency
dependencies {
implementation 'com.github.yohgenius:library-example:1.2.2'
}Step 1. Create a button in view
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_gradient"
tools:context=".MainActivity">
<Button
android:id="@+id/tanya_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="15dp"
android:text="Tanya Bestie" />
</RelativeLayout>Step 2. Set the onClickListener and intent destination
class MainActivity : AppCompatActivity() {
lateinit var tanyaBtn: Button
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_main)
tanyaBtn = findViewById(R.id.tanya_btn)
tanyaBtn.setOnClickListener {
val tanyaBestie = Intent(this, TanyaActivity::class.java)
startActivity(tanyaBestie)
}
}
}- Compile SDK 35
- Min SDK 29
- Android gradle plugin 8.3.2
- Kotlin 1.9.0
- openjdk17

