欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

如何給Android中的按鈕添加圖片功能

 更新時間:2017年02月22日 09:26:19   作者:Unique_849997563  
這篇文章主要介紹了Android中的按鈕加圖片功能,代碼簡單易懂,非常不錯,具有參考借鑒價值,需要的朋友可以參考下

在layout中建一個my_login.xml文件 代碼如下

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:background="@drawable/app_icon"
    android:orientation="vertical" >
    <Button
      android:id="@+id/startOrder_btn"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:background="@drawable/apply"
      android:textSize="25sp" >
    </Button>
    <Button
      android:id="@+id/managerOrder_btn"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:background="@drawable/apply"
      android:textSize="25sp" >
    </Button>
</LinearLayout>
--------------------------------------------------------------------------------------------------------------------------------------------
在drawable-xxhdpi中添加圖片
--------------------------------------------------------------------------------------------------------------------------------------------

在Mainactivity中添加如下代碼:

LayoutInflater inflater = LayoutInflater.from(mMainActivity);
  View layout=inflater.inflate(R.layout.my_login,null);
  ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(MainActivity.this, 2131099656);
  AlertDialog.Builder builder =new AlertDialog.Builder(contextThemeWrapper);
  builder.setView(layout);
  builder.setCancelable(false);
  builder.create().show();
  Button startOrder_btn=(Button) layout.findViewById(R.id.startOrder_btn);
  Button managerOrder_btn=(Button) layout.findViewById(R.id.managerOrder_btn);
  startOrder_btn.setOnClickListener(new OnClickListener(){
  public void onClick(View v) {
  //加上你要實現(xiàn)的代碼
  YSDKApi.login(ePlatform.QQ);
  }
  });
  managerOrder_btn.setOnClickListener(new OnClickListener(){
  public void onClick(View v) {//加上你要實現(xiàn)的代碼
  YSDKApi.login(ePlatform.WX);
  }
  });

以上所述是小編給大家介紹的給Android中的按鈕添加圖片功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關文章

最新評論