AIDE Tutorial - 7.1 Customize Toast
Watch the Video Below:
MainActivity.java
Watch the Video Below:
MainActivity.java
package com.kcgroup.CT;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.View.*;
import android.view.*;
public class MainActivity extends Activity
{ EditText et; Button btn;
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.main);
et=(EditText)findViewById(R.id.mainEditText);
btn=(Button)findViewById(R.id.mainButton);
btn.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View p1)
{
String text=et.getText().toString();
Toast.makeText(MainActivity.this,text,
Toast.LENGTH_SHORT).show();
// TODO: Implement this method
} }); }}
Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/mainEditText"
android:hint="Enter your own toast message"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:text="Create Toast"
android:id="@+id/mainButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
0 comments:
Post a Comment