zoukankan      html  css  js  c++  java
  • 第四次迭代目标

    这是最后一次迭代,我这次的认领的任务是设置界面的设计以及功能的实现

    下面是xml代码:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="#f5fffa"
        tools:context="com.edg.foodie.activity.SettingActivity">
    
        <LinearLayout
            android:id="@+id/settitle"
            android:background="@color/colorPrimary"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <Button
                android:layout_weight="1"
                android:layout_width="wrap_content"
                android:textSize="25dp"
                android:background="@color/colorPrimary"
                android:textColor="#ffffff"
                android:layout_height="wrap_content"
                android:text="@string/reback"
                android:id="@+id/setbackbtn"
                />
            <TextView
                android:layout_weight="10"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/setting"
                android:textSize="25dp"
                android:textColor="#ffffff"
                android:textAlignment="center"
                android:layout_toRightOf="@id/setbackbtn"
                />
        </LinearLayout>
    
        <LinearLayout
            android:paddingTop="10dp"
            android:id="@+id/font"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/settitle"
            android:layout_marginTop="10dp"
            >
            <TextView
                android:layout_width="110dp"
                android:layout_height="wrap_content"
                android:text="@string/font"
                android:textSize="25dp"
                />
            <Spinner
                android:layout_marginLeft="50dp"
                android:id="@+id/fontsize"
                android:layout_width="100dp"
                android:layout_height="25dp"
                android:entries="@array/size"
                >
            </Spinner>
        </LinearLayout>
    
        <LinearLayout
            android:paddingTop="10dp"
            android:id="@+id/update"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/font"
            >
            <TextView
                android:layout_width="110dp"
                android:layout_height="wrap_content"
                android:text="@string/update"
                android:textSize="25dp"
                />
            <ToggleButton
                android:background="#ffffff"
                android:layout_marginLeft="50dp"
                android:layout_width="100dp"
                android:layout_height="35dp"
                android:layout_gravity="center_horizontal"
                android:checked="true"
                android:textSize="20dp"
                android:textColor="#4F94CD"
                android:textOff="Off"
                android:textOn="On"
                />
        </LinearLayout>
    
        <LinearLayout
            android:paddingTop="10dp"
            android:id="@+id/cache"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/update"
            >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/cache"
                android:textSize="25dp"
                android:layout_weight="1"
                />
            <TextView
                android:id="@+id/cachesize"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="0.0MB"
                android:gravity="end"
                android:textSize="20dp"
    
                />
            <Button
                android:id="@+id/cleancache"
                android:background="#ffffff"
                android:layout_marginRight="10dp"
                android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/cache2"
                android:textSize="17dp"
                android:textColor="#4F94CD"
                />
        </LinearLayout>
    
        <View
            android:layout_below="@id/cache"
            android:layout_marginTop="20dp"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#000000"
            />
    
    
        <RelativeLayout
            android:layout_marginTop="50dp"
            android:id="@+id/advice"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/cache">
            <Button
                android:background="#ffffff"
                android:id="@+id/advicebtn"
                android:layout_width="200dp"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="@string/advice"
                android:textColor="#4F94CD"
                android:textSize="25dp"
                />
        </RelativeLayout>
    
        <RelativeLayout
            android:id="@+id/about"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/advice"
            android:layout_marginTop="20dp"
            >
            <Button
                android:background="#ffffff"
                android:id="@+id/aboutbtn"
                android:layout_width="200dp"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="@string/about"
                android:textSize="25dp"
                android:textColor="#4F94CD"
                />
    
        </RelativeLayout>
    
        <View
            android:layout_below="@id/about"
            android:layout_marginTop="20dp"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#000000"
            />
    
        <RelativeLayout
            android:id="@+id/restset"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/about"
            android:layout_marginTop="30dp"
            >
            <Button
                android:background="#ffffff"
                android:id="@+id/restsetbtn"
                android:layout_width="200dp"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="@string/restset"
                android:textSize="25dp"
                android:textColor="#4F94CD"
                />
        </RelativeLayout>
    
        <RelativeLayout
            android:id="@+id/exit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/restset"
            >
            <Button
                android:background="#ffffff"
                android:id="@+id/exitbtn"
                android:layout_width="200dp"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="@string/exit"
                android:textSize="25dp"
                android:textColor="#ff0000"
                />
        </RelativeLayout>
    </RelativeLayout>
    View Code

    这是功能代码:

    package com.edg.foodie.activity;
    
    import android.app.AlertDialog;
    import android.content.Intent;
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.view.View;
    import android.widget.Button;
    import android.widget.TextView;
    
    import com.edg.foodie.R;
    import com.edg.foodie.controller.DataCleanManager;
    
    public class SettingActivity extends AppCompatActivity {
    
        String size;
        TextView cache;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_setting);
    
            //显示缓存大小
            cache=(TextView)findViewById(R.id.cachesize);
            try {
                size = new DataCleanManager().getTotalCacheSize(this);
            } catch (Exception e) {
                e.printStackTrace();
            }
            cache.setText(size);
    
            //关于我们按钮的监听器
            Button about = (Button)findViewById(R.id.aboutbtn);
            about.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    startActivity(new Intent(SettingActivity.this, AboutUSActivity.class));
                }
            });
    
            //联系我们监听器
            findViewById(R.id.advicebtn).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    //    通过AlertDialog.Builder这个类来实例化我们的一个AlertDialog的对象
                    AlertDialog.Builder builder = new AlertDialog.Builder(SettingActivity.this);
                    //    设置Title的图标
                    builder.setTitle("联系方式");
                    //    设置Content来显示一个信息
                    builder.setMessage("邮箱:xu__kunfeng@163.com" + "
    " + "电话:0335-88888");
                    //    设置一个PositiveButton
                    builder.show();
                }
            });
    
            //清理缓存监听器
            findViewById(R.id.cleancache).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    DataCleanManager.clearAllCache(SettingActivity.this);
                    try {
                        size = new DataCleanManager().getTotalCacheSize(SettingActivity.this);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    cache.setText(size);
                }
            });
    
            //返回
            Button setbackbtn = (Button)findViewById(R.id.setbackbtn);
            setbackbtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    finish();
                }
            });
    
        }
    //    @Override
    //    public void onClick(View v) {
    //        switch (v.getId()) {
    //            case R.id.set:
    //                /**
    //                 * 判断两次密码的输入是否一致,一致则设置成功
    //                 *
    //                 */
    //                if(passwd.getText().toString().equals(comPasswd.getText().toString())) {
    //                    Toast.makeText(this, "设置成功", Toast.LENGTH_SHORT).show();
    //                    Intent intent = new Intent();
    //                    this.setResult(RESULT_OK, intent);
    //                    finish();
    //                }else{
    //                    Toast.makeText(this, "密码不一致", Toast.LENGTH_SHORT).show();
    //                }
    //                break ;
    //        }
    //    }
    
    //    @Override
    //    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    //        switch (requestCode){
    //            case 0:
    //                if (resultCode==RESULT_OK){
    //                    String returnData = data.getStringExtra("data_return") ;
    //                }
    //                break;
    //        }
    //    }
    }
    Setting
  • 相关阅读:
    java 接口中的成员变量与方法
    Spring BeanPostProcessor
    MySQL更改命令行默认分隔符
    java 动态代理
    《剑指offer》:[62]序列化二叉树
    group by语法
    Mysql两种引擎
    线程池大小设置
    Synchronized及其实现原理
    CAS ABA问题
  • 原文地址:https://www.cnblogs.com/huangxi1234/p/6872110.html
Copyright © 2011-2022 走看看