Created
February 26, 2013 09:36
-
-
Save cofearabi/5037279 to your computer and use it in GitHub Desktop.
Android sample . When buntton is clicked , it displays message with Toast.
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
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".MainActivity" > | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_centerHorizontal="true" | |
android:layout_centerVertical="true" | |
android:text="@string/hello_world" /> | |
<Button | |
android:id="@+id/button0" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="@string/toast" | |
android:layout_gravity="center"> | |
</Button> | |
</RelativeLayout> |
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.andtoast; | |
import android.os.Bundle; | |
import android.app.Activity; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.widget.Button; | |
import android.widget.Toast; | |
public class MainActivity extends Activity implements OnClickListener{ | |
private Button button0; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
button0=(Button)findViewById(R.id.button0); | |
button0.setOnClickListener(this); | |
} | |
public void onClick(View v){ | |
Toast.makeText(this, "ボタンが押されました。", Toast.LENGTH_LONG).show(); | |
} | |
} |
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
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<string name="app_name">AndToast</string> | |
<string name="hello_world">Hello world!</string> | |
<string name="toast">Toast!</string> | |
<string name="menu_settings">Settings</string> | |
</resources> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment