• 信息提示框


    Android-Toast(信息提示框)

     <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    <Button
        android:id="@+id/butA"  
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="长时间显示Toast"
        />
        <Button
        android:id="@+id/butB"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="短时间显示Toast"/>
    </LinearLayout>
    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     > <Button     android:id="@+id/butA"       android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="长时间显示Toast"     />     <Button     android:id="@+id/butB"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="短时间显示Toast"/> </LinearLayout>
    package com.zrf.demo;
    import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast;
    public class MyToastDemo extends Activity {     private Button butA=null;     private Button butB=null;     @Override     public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         super.setContentView(R.layout.main);         this.butA=(Button)super.findViewById(R.id.butA);         this.butB=(Button)super.findViewById(R.id.butB);         this.butA.setOnClickListener(new OnClickListenerImplLong());         this.butB.setOnClickListener(new OnClickListenerImplShort());     }     private class OnClickListenerImplShort implements OnClickListener{
            public void onClick(View view) {             Toast.makeText(MyToastDemo.this, "短时间显示的Toast信息提示框", Toast.LENGTH_SHORT).show();//显示Toast         }              }     private class OnClickListenerImplLong implements OnClickListener{
            public void onClick(View view) {             Toast.makeText(MyToastDemo.this, "长时间显示的Toast信息提示框", Toast.LENGTH_LONG).show();         }              } }
    package com.zrf.demo;
    import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast;
    public class MyToastDemo extends Activity {     private Button butA=null;     private Button butB=null;     @Override     public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         super.setContentView(R.layout.main);         this.butA=(Button)super.findViewById(R.id.butA);         this.butB=(Button)super.findViewById(R.id.butB);         this.butA.setOnClickListener(new OnClickListenerImplLong());         this.butB.setOnClickListener(new OnClickListenerImplShort());     }     private class OnClickListenerImplShort implements OnClickListener{
            public void onClick(View view) {             Toast.makeText(MyToastDemo.this, "短时间显示的Toast信息提示框", Toast.LENGTH_SHORT).show();//显示Toast         }              }     private class OnClickListenerImplLong implements OnClickListener{
            public void onClick(View view) {             Toast.makeText(MyToastDemo.this, "长时间显示的Toast信息提示框", Toast.LENGTH_LONG).show();         }              } }
  • 相关阅读:
    day2-元组 列表-赋值和深浅拷贝
    day1-bytes类型 三元运算 进制
    DAY02
    DAY02
    Python格式化、显示颜色
    DAY02
    DAY02
    DAY02
    DAY02
    DAY02
  • 原文地址:https://www.cnblogs.com/1396493331qq/p/6906754.html
Copyright © 2020-2023  润新知