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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 占位图怎么写[通俗易懂]

    占位图怎么写[通俗易懂]想必大家对占位图都不会陌生吧,非常犀利的一个工具,当然也有非常多优秀的网站为我们提供这样的接口。唯一遗憾的是国内的站点非常少。当然不是说国外的不行,正好相反,国外的那些占位图非常人性化,非常方便,唯一

    2022年8月4日
    4
  • 前端工程师vscode必备插件(20个)

    前端工程师vscode必备插件(20个)阶段:前端新手只会html、css、js1.Chinese汉化vscode2.TokyoNightMaterialTheme已经下架了,这个是目前来说个人认为vscode中最好看的主题。3.vscode-icons文件的图标,这个是看着最顺眼的图标。4.prettier代码格式化工具,代码自动格式化。(需配置,最下面放上代码)如果安装了vetur,则会产生冲突,需要手动右键格式化,选择prettier。5.openinbrowser打开浏览器插件。

    2022年7月25日
    11
  • 微型计算机的档次主要取决于,微型计算机的性能主要取决于

    微型计算机的档次主要取决于,微型计算机的性能主要取决于匿名用户1级2013-07-10回答“微型计算机的性能主要取决于什么?”主要看三大件,CPU,主板,内存。1、CPU:其功能主要是解释计算机指令以及处理计算机软件中的数据,他的速度快慢可以代表计算机处理数据的能力的高低。2、内存:它是与CPU进行沟通的桥梁,计算机中所有程序的运行都是在内存中进行的,因此内存的性能对计算机的影响非常大。3、主板:主板在整个微机系统中扮演着举足轻重的角色。主板的类型…

    2022年6月28日
    40
  • MySQL 自定义函数_mysql随机时间函数

    MySQL 自定义函数_mysql随机时间函数下面的自定义函数 中,注意delimiter的使用,使用了 group_concat()、find_in_set()  函数,delimiter$$use`test`$$dropfunctionifexists`queryOnePartnerIdById`$$createdefiner=`root`@`localhost`function`queryO

    2022年9月8日
    0
  • 流行计算机病毒有哪些,现在流行计算机病毒有哪些[通俗易懂]

    流行计算机病毒有哪些,现在流行计算机病毒有哪些[通俗易懂]现在流行计算机病毒有哪些现在流行计算机病毒有哪些现在流行的计算机病毒有很多!你有去了解过吗?下面由小编给你做出详细的现在流行计算机病毒介绍!希望对你有帮助!现在流行计算机病毒介绍一:国家计算机病毒应急处理中心通过对互联网的监测发现,近期出现一种恶意后门程序变种Backdoor_Agent.ADG。该变种运行后,会自我复制到受感染操作系统指定文件夹下,重命名为可执行文件。随后,该变种会释放操作系统中…

    2022年5月5日
    66
  • pycharm python安装教程_python环境安装教程

    pycharm python安装教程_python环境安装教程首先我们来安装python1、首先进入网站下载:点击打开链接(或自己输入网址https://www.python.org/downloads/),进入之后如下图,选择图中红色圈中区域进行下载。2、下载完成后如下图所示3、双击exe文件进行安装,如下图,并按照圈中区域进行设置,切记要勾选打钩的框,然后再点击Customizeinstallation进入到下一步:4、对于上图中,可以通过Browse…

    2022年8月25日
    4

发表回复

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

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