Created
November 3, 2019 11:03
-
-
Save robertohuertasm/43b7c2d696d23fb26edd89d3374431df to your computer and use it in GitHub Desktop.
rust_for_android_ios_flutter
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
package com.robertohuertas.rusty_android | |
import android.os.Bundle | |
import com.google.android.material.snackbar.Snackbar | |
import androidx.appcompat.app.AppCompatActivity | |
import android.view.Menu | |
import android.view.MenuItem | |
import android.widget.TextView | |
import kotlinx.android.synthetic.main.activity_main.* | |
import com.robertohuertas.rusty_android_lib.* | |
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
setSupportActionBar(toolbar) | |
loadRustyLib() | |
findViewById<TextView>(R.id.txt).let { | |
it?.text = hello("Rob") | |
} | |
var greeting2 = helloDirect("Rob Direct") | |
fab.setOnClickListener { view -> | |
Snackbar.make(view, greeting2, Snackbar.LENGTH_LONG) | |
.setAction("Action", null).show() | |
} | |
} | |
override fun onCreateOptionsMenu(menu: Menu): Boolean { | |
// Inflate the menu; this adds items to the action bar if it is present. | |
menuInflater.inflate(R.menu.menu_main, menu) | |
return true | |
} | |
override fun onOptionsItemSelected(item: MenuItem): Boolean { | |
// Handle action bar item clicks here. The action bar will | |
// automatically handle clicks on the Home/Up button, so long | |
// as you specify a parent activity in AndroidManifest.xml. | |
return when (item.itemId) { | |
R.id.action_settings -> true | |
else -> super.onOptionsItemSelected(item) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment