目录
1.个人主页界面的设计:fragment_blank.xml
2.个人主页功能的实现类:BlankFragment.java
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="?attr/colorOnPrimary"
tools:context=".ui.blank.BlankFragment">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:background="?attr/colorPrimary">
</androidx.appcompat.widget.Toolbar>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="70dp"
app:cardCornerRadius="10dp"
app:cardElevation="0dp"
>
</androidx.cardview.widget.CardView>
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/app_img"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginTop="35dp"
android:layout_centerHorizontal="true"
android:src="@drawable/app_img" />
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/app_img"
android:layout_marginBottom="5dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:maxLength="6"
android:text="账单日记"
android:textColor="@android:color/black"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/liner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:layout_margin="20dp"
android:orientation="horizontal">
<TextView
android:id="@+id/signup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="center"
android:text="每日签到"
android:textColor="#333333"
android:layout_marginTop="5dp"
android:textSize="15sp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="6">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:text="累计签到:"
android:textColor="#333333"
android:textSize="15sp" />
<TextView
android:id="@+id/clock_day"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:text="0"
android:textColor="#F43678"
android:textSize="20sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="center"
android:text="天"
android:textColor="#333333"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginBottom="30dp"
android:layout_below="@id/liner"
android:background="@drawable/kuang"
android:layout_marginTop="50dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#1A000000"/>
<RelativeLayout
android:id="@+id/budget_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:clickable="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/budget"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="预算中心"
android:textSize="16sp"
android:layout_marginLeft="70dp"
android:layout_centerVertical="true"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/right"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#1A000000"/>
<RelativeLayout
android:id="@+id/usehelp_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:clickable="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/usinghelp"
android:layout_marginLeft="20dp"
android:layout_centerVertical="true"/>
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="使用帮助"
android:textSize="16sp"
android:layout_marginLeft="70dp"
android:layout_centerVertical="true"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/right"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#1A000000"/>
<RelativeLayout
android:id="@+id/about_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:clickable="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/about"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="关于我们"
android:textSize="16sp"
android:layout_marginLeft="70dp"
android:layout_centerVertical="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/right"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#1A000000"/>
<RelativeLayout
android:id="@+id/setting_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:clickable="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/setting"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="设 置"
android:textSize="16sp"
android:layout_marginLeft="70dp"
android:layout_centerVertical="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/right"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#1A000000"/>
</LinearLayout>
</RelativeLayout>
package com.example.ji_zhang_ben.ui.blank;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.example.ji_zhang_ben.R;
public class BlankFragment extends Fragment implements View.OnClickListener{
TextView signup,clock_day;//每日签到,显示签到的天数
RelativeLayout budget_btn,usehelp_btn,about_btn,setting_btn; //预算中心,使用帮助,关于我们,设置
View sigup_view; //签到弹窗视图
AlertDialog write;
SharedPreferences sp;
SharedPreferences.Editor editor;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view= inflater.inflate(R.layout.fragment_blank, container, false);
budget_btn = view.findViewById(R.id.budget_btn);
usehelp_btn = view.findViewById(R.id.usehelp_btn);
about_btn = view.findViewById(R.id.about_btn);
setting_btn = view.findViewById(R.id.setting_btn);
signup = view.findViewById(R.id.signup);
clock_day = view.findViewById(R.id.clock_day);
budget_btn.setOnClickListener(this);
usehelp_btn.setOnClickListener(this);
about_btn.setOnClickListener(this);
setting_btn.setOnClickListener(this);
signup.setOnClickListener(this);
//设置累计签到的天数
sp =getActivity().getSharedPreferences("tice", Context.MODE_PRIVATE);
clock_day.setText(sp.getString("tice","0"));
return view;
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.signup://签到
setSignup();
break;
case R.id.budget_btn://预算中心
Intent intent2 = new Intent(getContext(),BudgetActivity.class);
startActivity(intent2);
break;
case R.id.usehelp_btn://使用帮助
Intent intent3 = new Intent(getContext(),UsehelpActivity.class);
startActivity(intent3);
break;
case R.id.about_btn://关于我们
Intent intent4 = new Intent(getContext(),AboutActivity.class);
startActivity(intent4);
break;
case R.id.setting_btn://设置
Intent intent5 = new Intent(getContext(),SettingActivity.class);
startActivity(intent5);
break;
}
}
//签到功能的实现
public void setSignup(){
//显示签到成功视图
write = new AlertDialog.Builder(getActivity()).create();
sigup_view = LayoutInflater.from(getActivity()).inflate(R.layout.pop_up_signup,null);
write.setView(sigup_view);
write.show();
int count = Integer.parseInt(clock_day.getText().toString())+1;
editor = sp.edit();
editor.putString("tice",Integer.toString(count));
editor.commit(); //写入
onResume();//刷新
}
@Override
public void onResume() {
super.onResume();
SharedPreferences sp =getActivity().getSharedPreferences("tice",Context.MODE_PRIVATE);
clock_day.setText(sp.getString("tice","0"));
}
}
补充说明:注意配置AndroidManifest.xml文件
<activity
android:name=".ui.blank.BudgetActivity"
android:exported="false" />
<activity
android:name=".ui.blank.SettingActivity"
android:exported="false" />
<activity
android:name=".ui.blank.AboutActivity"
android:exported="false" />
<activity
android:name=".ui.blank.UsehelpActivity"
android:exported="false" />
自定义弹窗布局文件:pop_up_signup.xml,用于显示签到成功
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="50dp"
android:layout_gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:layout_gravity="center"
android:src="@mipmap/laud"></ImageView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_gravity="center"
android:text="签到成功"
android:textSize="30sp"
android:textStyle="bold"></TextView>
</LinearLayout>
</LinearLayout>
累计签到的天数,采用的是SharedPreferences存储,一开始先获取里面的值,然后设置控件id:clock_day的值。
//设置累计签到的天数
sp =getActivity().getSharedPreferences("tice", Context.MODE_PRIVATE);
clock_day.setText(sp.getString("tice","0"));
当点击 每日签到 时,跳出弹窗提示签到成功,同时获取当前累计签到的天数值并加1,然后将结果写入SharedPreferences中,并刷新。
//签到功能的实现
public void setSignup(){
//显示签到成功视图
write = new AlertDialog.Builder(getActivity()).create();
sigup_view = LayoutInflater.from(getActivity()).inflate(R.layout.pop_up_signup,null);
write.setView(sigup_view);
write.show();
int count = Integer.parseInt(clock_day.getText().toString())+1;
editor = sp.edit();
editor.putString("tice",Integer.toString(count));
editor.commit(); //写入
onResume();//刷新
}

我有一个用户工厂。我希望默认情况下确认用户。但是鉴于unconfirmed特征,我不希望它们被确认。虽然我有一个基于实现细节而不是抽象的工作实现,但我想知道如何正确地做到这一点。factory:userdoafter(:create)do|user,evaluator|#unwantedimplementationdetailshereunlessFactoryGirl.factories[:user].defined_traits.map(&:name).include?(:unconfirmed)user.confirm!endendtrait:unconfirmeddoenden
华为OD机试题本篇题目:明明的随机数题目输入描述输出描述:示例1输入输出说明代码编写思路最近更新的博客华为od2023|什么是华为od,od薪资待遇,od机试题清单华为OD机试真题大全,用Python解华为机试题|机试宝典【华为OD机试】全流程解析+经验分享,题型分享,防作弊指南华为o
C#实现简易绘图工具一.引言实验目的:通过制作窗体应用程序(C#画图软件),熟悉基本的窗体设计过程以及控件设计,事件处理等,熟悉使用C#的winform窗体进行绘图的基本步骤,对于面向对象编程有更加深刻的体会.Tutorial任务设计一个具有基本功能的画图软件**·包括简单的新建文件,保存,重新绘图等功能**·实现一些基本图形的绘制,包括铅笔和基本形状等,学习橡皮工具的创建**·设计一个合理舒适的UI界面**注明:你可能需要先了解一些关于winform窗体应用程序绘图的基本知识,以及关于GDI+类和结构的知识二.实验环境Windows系统下的visualstudio2017C#窗体应用程序三.
MIMO技术的优缺点优点通过下面三个增益来总体概括:阵列增益。阵列增益是指由于接收机通过对接收信号的相干合并而活得的平均SNR的提高。在发射机不知道信道信息的情况下,MIMO系统可以获得的阵列增益与接收天线数成正比复用增益。在采用空间复用方案的MIMO系统中,可以获得复用增益,即信道容量成倍增加。信道容量的增加与min(Nt,Nr)成正比分集增益。在采用空间分集方案的MIMO系统中,可以获得分集增益,即可靠性性能的改善。分集增益用独立衰落支路数来描述,即分集指数。在使用了空时编码的MIMO系统中,由于接收天线或发射天线之间的间距较远,可认为它们各自的大尺度衰落是相互独立的,因此分布式MIMO
遍历文件夹我们通常是使用递归进行操作,这种方式比较简单,也比较容易理解。本文为大家介绍另一种不使用递归的方式,由于没有使用递归,只用到了循环和集合,所以效率更高一些!一、使用递归遍历文件夹整体思路1、使用File封装初始目录,2、打印这个目录3、获取这个目录下所有的子文件和子目录的数组。4、遍历这个数组,取出每个File对象4-1、如果File是否是一个文件,打印4-2、否则就是一个目录,递归调用代码实现publicclassSearchFile{publicstaticvoidmain(String[]args){//初始目录Filedir=newFile("d:/Dev");Datebeg
通常,数组被实现为内存块,集合被实现为HashMap,有序集合被实现为跳跃列表。在Ruby中也是如此吗?我正在尝试从性能和内存占用方面评估Ruby中不同容器的使用情况 最佳答案 数组是Ruby核心库的一部分。每个Ruby实现都有自己的数组实现。Ruby语言规范只规定了Ruby数组的行为,并没有规定任何特定的实现策略。它甚至没有指定任何会强制或至少建议特定实现策略的性能约束。然而,大多数Rubyist对数组的性能特征有一些期望,这会迫使不符合它们的实现变得默默无闻,因为实际上没有人会使用它:插入、前置或追加以及删除元素的最坏情况步骤复
在ruby中,你可以这样做:classThingpublicdeff1puts"f1"endprivatedeff2puts"f2"endpublicdeff3puts"f3"endprivatedeff4puts"f4"endend现在f1和f3是公共(public)的,f2和f4是私有(private)的。内部发生了什么,允许您调用一个类方法,然后更改方法定义?我怎样才能实现相同的功能(表面上是创建我自己的java之类的注释)例如...classThingfundeff1puts"hey"endnotfundeff2puts"hey"endendfun和notfun将更改以下函数定
我已经有很多两个值数组,例如下面的例子ary=[[1,2],[2,3],[1,3],[4,5],[5,6],[4,7],[7,8],[4,8]]我想把它们分组到[1,2,3],[4,5],[5,6],[4,7,8]因为意思是1和2有关系,2和3有关系,1和3有关系,所以1,2,3都有关系我如何通过ruby库或任何算法来做到这一点? 最佳答案 这是基本Bron–Kerboschalgorithm的Ruby实现:classGraphdefinitialize(edges)@edges=edgesenddeffind_maximum_
我目前有一个reddit克隆类型的网站。我正在尝试根据我的用户之前喜欢的帖子推荐帖子。看起来K最近邻或k均值是执行此操作的最佳方法。我似乎无法理解如何实际实现它。我看过一些数学公式(例如k表示维基百科页面),但它们对我来说并没有真正意义。有人可以推荐一些伪代码,或者可以查看的地方,以便我更好地了解如何执行此操作吗? 最佳答案 K最近邻(又名KNN)是一种分类算法。基本上,您采用包含N个项目的训练组并对它们进行分类。如何对它们进行分类完全取决于您的数据,以及您认为该数据的重要分类特征是什么。在您的示例中,这可能是帖子类别、谁发布了该项
我正在阅读“Rails3Way”,在第39页,它显示了匹配:to=>重定向方法的代码示例。在该方法中存在以下代码。虽然我知道模对数字有什么作用,但我不确定下面的%是做什么的,因为路径和参数显然都不是数字。如果有人能帮助我理解%在这种情况下的用法,我将不胜感激。proc{|params|path%params} 最佳答案 这可能是String#%与其他语言中的sprintf非常相似的方法:'%05d'%10#=>"00010"它可以接受单个参数或数组:'%.3f%s'%[10.341412,'samples']#=>"10.341sa