<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                使用Toast顯示提示信息框:不僅可以顯示簡單的提示信息,還可以顯示自定義的View 使用Toast顯示提示信息非常簡單: 1,調用Toast的構造器或者makeText()靜態方法創建一個Toast對象 2,調用Toast的方法來設置消息提示的對齊方式,頁邊距等 3,調用Toast的show()方法將它顯示出來 大部分時候Toast顯示的是簡單的消息文本; ~~~ Toast.makeText(MainActivity.this,?"簡單的提示信息",?Toast.LENGTH_SHORT).show()?? ~~~ 當要顯示自定義的View,包含圖片,列表之類的復雜提示時,需要調用Toast構造器創建實例,再調用setView方法設置該Toast的View組件 activity_main.xml ~~~ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:id="@+id/simple" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="顯示簡單提示" /> <Button android:id="@+id/bn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="顯示帶圖片的提示" /> </LinearLayout> ~~~ MainActivity.java ~~~ package com.example.toast; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.view.Gravity; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button simple = (Button) findViewById(R.id.simple); // 為按鈕的單擊事件綁定事件監聽器 simple.setOnClickListener(new OnClickListener() { @Override public void onClick(View source) { // 創建一個Toast提示信息 Toast toast = Toast.makeText(MainActivity.this , "簡單的提示信息" // 設置該Toast提示信息的持續時間 , Toast.LENGTH_SHORT); toast.show(); //或者Toast.makeText(MainActivity.this, "簡單的提示信息", Toast.LENGTH_SHORT).show() } }); Button bn = (Button) findViewById(R.id.bn); // 為按鈕的單擊事件綁定事件監聽器 bn.setOnClickListener(new OnClickListener() { @Override public void onClick(View source) { // 創建一個Toast提示信息 Toast toast = new Toast(MainActivity.this); // 設置Toast的顯示位置 toast.setGravity(Gravity.CENTER, 0, 0); // 創建一個ImageView ImageView image = new ImageView(MainActivity.this); image.setImageResource(R.drawable.tools); // 創建一個LinearLayout容器 LinearLayout ll = new LinearLayout(MainActivity.this); // 向LinearLayout中添加圖片、原有的View ll.addView(image); // 創建一個ImageView TextView textView = new TextView(MainActivity.this); textView.setText("帶圖片的提示信"); // 設置文本框內字體的大小和顏色 textView.setTextSize(30); textView.setTextColor(Color.MAGENTA); ll.addView(textView); // 設置Toast顯示自定義View ,Toast里面可以設置View toast.setView(ll); // 設置Toast的顯示時間 toast.setDuration(Toast.LENGTH_LONG); toast.show(); } }); } } ~~~ ![](https://box.kancloud.cn/2016-03-10_56e0d9aeace97.jpg) ![](https://box.kancloud.cn/2016-03-10_56e0d9aecd2f8.jpg)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看