-
-
Save codeforfun-jp/943f8d96826226fe0950b919da720d8e to your computer and use it in GitHub Desktop.
How to use Snackbar 5
This file contains 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.example.sample; | |
import androidx.appcompat.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import com.google.android.material.snackbar.Snackbar; | |
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
Snackbar.make(findViewById(R.id.layout), "こんにちは!", Snackbar.LENGTH_SHORT) | |
.show(); | |
} | |
public void showSnackbar(View view) { | |
Snackbar.make(view, "ここにメッセージを表示します", Snackbar.LENGTH_SHORT) | |
.setAction("ボタン", new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
// ボタンを押した時の処理 | |
} | |
}) | |
.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment