This file contains hidden or 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
class ListActivity: AppCompatActivity { | |
private val REQUEST_FORM = 1 | |
onCreate(...){...} | |
fun startFormActivity() { | |
val intent = Intent(this, FormActivity::class.java) | |
startActivityForResult(intent, REQUEST_FORM) | |
} |
This file contains hidden or 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
class FormActivity: AppCompatActivity { | |
onCreate(...){...} | |
fun sendFormAndGoBack(name: String) { | |
// if you want to send any type of data back, such as an object, string, int etc | |
// you have to create an intent and use this bit of code | |
// otherwise you can just use setResult(Activity.RESULT_OK) and finish() | |
val resultIntent = Intent() |
This file contains hidden or 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
class ListActivity: AppCompatActivity { | |
private val REQUEST_FORM = 1 | |
onCreate(...){...} | |
fun startFormActivity() {...} | |
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | |
// check if the requestCode is the wanted one and if the result is what we are expecting |
This file contains hidden or 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
<resources> | |
<style name="HeadlineText"> | |
<item name="android:textSize">?attr/headlineTextSize</item> | |
<item name="android:textColor">@color/dark_concrete</item> | |
</style> | |
</resources> |
This file contains hidden or 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
<LinearLayout> | |
<TextView | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="Billing Info" | |
style="@style/HeadlineText" /> | |
</LinearLayout> |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:orientation="vertical" | |
android:layout_width="134dp" | |
android:layout_height="154dp" | |
android:background="@drawable/grey_rounded_background" | |
android:gravity="center" | |
android:padding="16dp"> |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<declare-styleable name="BenefitView"> | |
<attr name="image" format="reference"/> | |
<attr name="text" format="string"/> | |
</declare-styleable> | |
</resources> |
This file contains hidden or 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
class BenefitView(context: Context, attrs: AttributeSet): LinearLayout(context, attrs) { | |
init { | |
inflate(context, R.layout.benefit_view, this) | |
val imageView: ImageView = findViewById(R.id.image) | |
val textView: TextView = findViewById(R.id.caption) | |
val attributes = context.obtainStyledAttributes(attrs, R.styleable.BenefitView) | |
imageView.setImageDrawable(attributes.getDrawable(R.styleable.BenefitView_image)) |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.ConstraintLayout | |
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:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context="com.iacovelli.customview.MainActivity"> | |
<HorizontalScrollView |
This file contains hidden or 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
<com.iacovelli.customview.BenefitView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
app:text="Apply and chat with our hosts" | |
app:image="@drawable/first_image" | |
android:layout_marginEnd="12dp"/> |