Skip to content

Instantly share code, notes, and snippets.

View farooqkhan003's full-sized avatar
🎯
Focusing

Farooq Khan farooqkhan003

🎯
Focusing
  • Lahore, Pakistan
View GitHub Profile
var toast: Toast = Toast(this)
toast.createToast(this, "Hello From Android Tech Point", Gravity.CENTER_VERTICAL, Toast.LENGTH_LONG)
/**
* Created by android tech point on 9/22/2017.
*/
fun Toast.createToast(context: Context, message:String, gravity:Int, duration:Int){
val inflater:LayoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
/*first parameter is the layout you made
second parameter is the root view in that xml
*/
val layout = inflater.inflate(R.layout.custom_toast_layout, (context as Activity).findViewById<ViewGroup>(R.id.custom_toast_container))
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/custom_toast_container"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="8dp"
android:background="#DAAA"
>
<ImageView android:src="@drawable/ic_launcher_background"
package com.example.farooq.firstappwithkotlin
import android.support.v7.widget.RecyclerView
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
package com.example.farooq.firstappwithkotlin
import android.graphics.Bitmap
/**
* Created by androidtechpoint.blogspot.com on 9/12/2017.
*/
data class MyData(var text:String, var image:Bitmap)
<?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:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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.example.farooq.firstappwithkotlin.MainActivity">
<android.support.v7.widget.RecyclerView
package com.example.farooq.firstappwithkotlin
import android.graphics.BitmapFactory
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.widget.LinearLayout
class MainActivity : AppCompatActivity() {
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<cache-path name="shared_images" path="images/"/>
</paths>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.vd.viewtobitmap.fileprovider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>