作业五

作业五,第1张

概述<RelativeLayoutxmlns:android="http://schemas.android.com/apkes/android"xmlns:tools="http://schemas.android.comools"android:layout_width="match_parent"android:id="@+idt1"android:layout_heigh

<relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:tools="http://schemas.androID.com/tools"    androID:layout_wIDth="match_parent"    androID:ID="@+ID/rt1"    androID:layout_height="match_parent"    androID:paddingBottom="@dimen/activity_vertical_margin"    androID:paddingleft="@dimen/activity_horizontal_margin"    androID:paddingRight="@dimen/activity_horizontal_margin"    androID:paddingtop="@dimen/activity_vertical_margin"    tools:context="com.example.beijing.MainActivity" >    <TextVIEw                androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:text="@string/hello_world" />    <button        androID:ID="@+ID/button1"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_centerHorizontal="true"        androID:layout_centerVertical="true"        androID:text="选择变色"         androID:onClick="click"        /></relativeLayout>
package com.example.aaaaa;import androID.support.v7.app.ActionBaractivity;import androID.app.AlertDialog;import androID.content.DialogInterface;import androID.graphics.color;import androID.os.Bundle;import androID.vIEw.Menu;import androID.vIEw.MenuItem;import androID.vIEw.VIEw;import androID.Widget.relativeLayout;import androID.Widget.TextVIEw;import androID.Widget.Toast;public class MainActivity extends ActionBaractivity {    public int tv = 0, r = 0, g = 0, b = 0;    public int[] arr = { color.rgb(0, 0, 255), color.rgb(255, 0, 0),color.rgb(255, 255, 255), color.rgb(0, 0, 0), color.rgb(0, 255, 0) };    @OverrIDe    protected voID onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentVIEw(R.layout.activity_main);    }    public voID click(VIEw v) {        AlertDialog dialog;        AlertDialog.Builder builder = new AlertDialog.Builder(this)                .setTitle("设置字体大小")                // 设置标题                .setIcon(R.drawable.ic_launcher)                .setSingleChoiceItems(new String[] { "蓝色", "红色", "白色", "黑色", "绿色" }, 0,new DialogInterface.OnClickListener() {                            public voID onClick(DialogInterface dialog,                                    int which) {                                // 点单选按钮时发生的事件,这里which表示你点的单选按钮是第几个                                tv = which;                            }                        })                .setPositivebutton("确定", new DialogInterface.OnClickListener() {                    @OverrIDe                    public voID onClick(DialogInterface dialog, int which) {                        // 点确定按钮时发生的事件                        relativeLayout rl = (relativeLayout) findVIEwByID(R.ID.rt1);                        rl.setBackgroundcolor(arr[tv]);                        Toast.makeText(MainActivity.this, "修改成功!!", 0).show();                    }                })                .setNegativebutton("取消", new DialogInterface.OnClickListener() {                    @OverrIDe                    public voID onClick(DialogInterface dialog, int which) {                        dialog.dismiss();                    }                });        dialog = builder.create();        dialog.show();    }}

 

总结

以上是内存溢出为你收集整理的作业五全部内容,希望文章能够帮你解决作业五所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1102845.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存