最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android實現(xiàn)Toast提示框圖文并存的方法

 更新時間:2016年01月29日 15:08:54   作者:馬到成功  
這篇文章主要介紹了Android實現(xiàn)Toast提示框圖文并存的方法,實例分析了Toast提示框的參數(shù)設(shè)置及圖文調(diào)用的相關(guān)技巧,需要的朋友可以參考下

本文實例講述了Android實現(xiàn)Toast提示框圖文并存的方法。分享給大家供大家參考,具體如下:

程序如下:

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.text.util.Linkify;
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 A05Activity extends Activity {
 private Button b;
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    b=(Button)findViewById(R.id.button);
    b.setText("顯示Toast");
    b.setBackgroundColor(Color.GREEN);
    b.setOnClickListener(new OnClickListener(){
  @Override
  public void onClick(View v) {
  // TODO Auto-generated method stub
  ImageView iv=new ImageView(A05Activity.this);
     iv.setImageResource(R.drawable.icon);
     TextView tv=new TextView(A05Activity.this);
     tv.setText(R.string.title);
     LinearLayout ll=new LinearLayout(A05Activity.this);
     //判斷TextView中的內(nèi)容是什么格式,并與系統(tǒng)連接
     Linkify.addLinks(tv, Linkify.PHONE_NUMBERS|Linkify.EMAIL_ADDRESSES|Linkify.WEB_URLS);
  Toast t=Toast.makeText(A05Activity.this, tv.getText(), Toast.LENGTH_LONG);
  View v1=t.getView();
  ll.setOrientation(LinearLayout.VERTICAL);
  ll.addView(iv);
  ll.addView(v1);
  t.setView(ll);
  //設(shè)置Toast對象在手機中的相對位置
  t.setGravity(Gravity.CENTER, 50, 50);
  t.show();
  }
    });
  }
}

注意:因為Toast屬于Activiyt里的Context,所以在Toast里面的連接是無法單擊的。比如在Toast中存在網(wǎng)址等內(nèi)容是無法在Toast里面雙擊打開的。

更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android控件用法總結(jié)》及《Android開發(fā)入門與進階教程

希望本文所述對大家Android程序設(shè)計有所幫助。

相關(guān)文章

最新評論

武川县| 莲花县| 崇仁县| 二手房| 丰县| 三明市| 宾阳县| 鲁山县| 葵青区| 景泰县| 英超| 合阳县| 宜君县| 宁强县| 三江| 阿坝县| 泸定县| 遂川县| 济阳县| 鹰潭市| 泰兴市| 伊金霍洛旗| 汽车| 镇雄县| 天全县| 稻城县| 密山市| 浑源县| 双流县| 全椒县| 沙河市| 惠州市| 灵石县| 合水县| 登封市| 浙江省| 万源市| 阿坝| 信丰县| 丹棱县| 碌曲县|