android项目实战手机安全卫士_恢复2345安全卫士主界面

android项目实战手机安全卫士_恢复2345安全卫士主界面主界面的布局文件

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

主界面的布局文件

<?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"
    android:background="@color/backgroundcolor"
    android:orientation="vertical" >

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:background="@drawable/title_background"
        android:gravity="center_horizontal|center_vertical"
        android:orientation="vertical" >
        <TextView 
                    android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#FFF8F8F8"
        android:textSize="22sp"
        android:text="山寨手机卫士"
            />
    </LinearLayout>

    <GridView
        android:id="@+id/gv_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="10dip"
        android:horizontalSpacing="10dip"
        android:numColumns="3"
        android:verticalSpacing="10dip" >
    </GridView>

</LinearLayout>

适配器

package cn.itcast.mobilesafe.adapter;

import cn.itcast.mobilesafe.R;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MainUIAdapter extends BaseAdapter {
	private static final String TAG = "MainUIAdapter";
	private Context context;
	private LayoutInflater inflater;
	private static ImageView iv_icon;
	private static TextView tv_name;
	private SharedPreferences sp;
	
	public MainUIAdapter(Context context) {
		this.context = context;
		inflater = LayoutInflater.from(context);
		sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
	}

	private static String[] names = { "手机防盗", "通讯卫士", "软件管理", "任务管理", "流量管理",
			"手机杀毒", "系统优化", "高级工具", "设置中心" };
	private static int[] icons = { R.drawable.widget05, R.drawable.widget02,
			R.drawable.widget01, R.drawable.widget07, R.drawable.widget05,
			R.drawable.widget04, R.drawable.widget06, R.drawable.widget03,
			R.drawable.widget08 };

	public int getCount() {
		
		return names.length;
	}

	public Object getItem(int position) {
		
		return position;
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		// getview的方法被调用了多少次?
		// 9
		// gridview 控件bug 
		// won't fix 
		// 使用静态的变量引用 减少内存中申请的引用的个数 
		
		Log.i(TAG,"getview "+ position);
		View view = inflater.inflate(R.layout.mainscreen_item, null);
		iv_icon =  (ImageView) view.findViewById(R.id.iv_main_icon);
		tv_name =  (TextView) view.findViewById(R.id.tv_main_name);
		iv_icon.setImageResource(icons[position]);
		tv_name.setText(names[position]);
		if(position==0){
			String name = sp.getString("lost_name", null);
			if(name!=null){
				tv_name.setText(name);
			}
		}
		
		return view;
	}

}

mainscreen_item

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="100dip"
    android:layout_height="100dip"
    android:gravity="center_horizontal"
    android:background="@drawable/item_background"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/iv_main_icon"
        android:layout_width="60dip"
        android:layout_height="60dip"
        android:scaleType="fitXY"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/tv_main_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="功能名字"
        android:textColor="@color/textcolor"
        android:textSize="18sp" />

</LinearLayout>

样式文件

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <stroke
        android:width="0.5dip"
        android:color="#ff505050" />

    <corners android:radius="2dip" >
    </corners>

	<gradient android:startColor="#ff404040"
	    android:centerColor="#ff383838"
	    android:endColor="#ff404040"
	    />
</shape>

效果

android项目实战手机安全卫士_恢复2345安全卫士主界面

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/190157.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 遗传算法实例解析_遗传算法例子

    遗传算法实例解析_遗传算法例子遗传算法实例及MATLAB程序解析遗传算法GeneticAlgorithms,GA)是一种基于自然选择原理和自然遗传机制的搜索(寻优)算法,它是模拟自然界中的生命进化机制,在人工系统中实现特定目标的优化。遗传算法的实质是通过群体搜索技术,根据适者生存的原则逐代进化,最终得到最优解或准最优解。它必须做以下操作∶初始群体的产生、求每一个体的适应度、根据适者生存的原则选择优良个体、被选出的优良个体两两配对,通过随机交叉其染色体的基因并随机变异某些染色体的基因生成下一代群体,按此方法使群体逐代进化,直到满足进化

    2022年9月13日
    6
  • QT/MFC面试题[通俗易懂]

    QT/MFC面试题[通俗易懂]1、QT信号槽机制的优缺点1)QT信号槽机制的引用精简了程序员的代码量2)QT的信号可以对应多个槽(但他们的调用顺序是随机),也可以多个槽映射一个信号3)QT的信号槽的建立和解除绑定十分自由4)信号槽同真正的回调函数比起来时间的耗损还是很大的,所有在嵌入式实时系统中应当慎用5)信号槽的参数限定很多例如不能携带模板类参数,不能出现宏定义等等

    2022年6月25日
    47
  • @RequestBody的使用[通俗易懂]

    @RequestBody的使用[通俗易懂]提示:建议一定要看后面的@RequestBody的核心逻辑源码以及六个重要结论!本文前半部分的内容都是一些基本知识常识,可选择性跳过。声明:本文是基于SpringBoot,进行的演示说明。基础知识介绍:@RequestBody主要用来接收前端传递给后端的json字符串中的数据的(请求体中的数据的);GET方式无请求体,所以使用@RequestBo…

    2022年4月27日
    74
  • python2 nonlocal_Python nonlocal

    python2 nonlocal_Python nonlocalpython3:变量作用域及global,nonlocal的用法在Python程序中声明、改变、查找变量名时,都是在一个保存变量名的命名空间中进行中,此命名空间亦称为变量的作用域。python的作用域是静态的,在代码中变量名被赋值的位置决定了该变量能被访问的范围。即Python变量的作用域由变量所在源代码中的位置决定.变量作用域之LENGBL=Local局部作用域E=…

    2025年9月20日
    10
  • Android移动开发-VR全景照片简单实现

    Android移动开发-VR全景照片简单实现VR技术的热度每年都在增长,在购物、旅游等方面运用度很高。该项目引用了Google的vr:sdk-panowidget依赖库,通过VrPanoramaView,简单实现在手机上查看全景照片,下面是项目介绍。build.gradle(Module:app)需要导入依赖:dependencies{implementation‘com.google.vr:sdk-panowidget:1.30.0’}布局文件activity_main.xml,调

    2022年4月7日
    297
  • linux下安装ffmpeg_linux 当前时间

    linux下安装ffmpeg_linux 当前时间linuxffmpeg安装ffmpeg安装不会吧这都22年了还有人问ffmpeg安装第一步我们先去下载资源包这里是4.4版本wgethttp://www.ffmpeg.org/releases/ffmpeg-4.4.tar.gz第二步解压资源包tar-zxvfffmpeg-4.4.tar.gz第3步创建安装目录我是安装在##我是安装在/www/server/ffmpeg下面mkdirffmpeg第4步返回解压目录cdffmpeg-4.

    2025年11月4日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号