Skip to content

Instantly share code, notes, and snippets.

@Debdutta-Panda
Created June 10, 2022 15:16
Show Gist options
  • Select an option

  • Save Debdutta-Panda/5e33820746541181fe58ecc9c0697e07 to your computer and use it in GitHub Desktop.

Select an option

Save Debdutta-Panda/5e33820746541181fe58ecc9c0697e07 to your computer and use it in GitHub Desktop.
MyMarker_phase_1_MainActivity
package com.debduttapanda.mymarker
import android.content.Context
import android.os.Bundle
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Button
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import com.debduttapanda.mymarker.ui.theme.MyMarkerTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MyMarkerTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
) {
val context = LocalContext.current
MainContent(context)
}
}
}
}
}
@Composable
private fun MainContent(context: Context) {
Box(
contentAlignment = Alignment.Center
){
Button(onClick = {
Toast.makeText(context, "Hi", Toast.LENGTH_SHORT).show()
}) {
Text("Say Hi")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment