在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) {
//加上你要实现的代码
YSDKApi.login(ePlatform.QQ);
}
});
managerOrder_btn.setOnClickListener(new OnClickListener(){
public void onClick(View v) {//加上你要实现的代码
YSDKApi.login(ePlatform.WX);
}
});
以上所述是小编给大家介绍的给Android中的按钮添加图片功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对亿速云网站的支持!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。