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安全卫士主界面

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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)
blank

相关推荐

  • 爱思唯尔(Elsevier)出版公司_斯普林格期刊

    爱思唯尔(Elsevier)出版公司_斯普林格期刊首先请正确安装latex软件!介绍网址:https://www.elsevier.com/authors/author-schemas/latex-instructions模板elsarticle.cls下载网址:http://www.ctan.org/tex-archive/macros/latex/contrib/elsarticle直接下载:Down­load网页打不…

    2022年10月11日
  • windows10 bat命令获取日期时间「建议收藏」

    windows10 bat命令获取日期时间「建议收藏」系统版本win10英文OSWindowsEdition:Windows10ProSettings-Language:English(UnitedStates)获取日期命令完整的日期:date(输出如下图)裁剪方法:echo%date:~起点位,数据长度%【英文版】对date进行裁剪获取年月日:年:echo%date:~6,4%月:echo%date:~0,2%日:echo%date:~3,2%年月日:%date:~6,4%-%date:~0,2%-%date

  • java项目开发实例_java项目总结

    java项目开发实例_java项目总结 根据网上的例子,写的flexBlazeDS 框架与java访问,实现。

    2022年10月21日
  • x201换风扇_x201i拆机风扇清理怎么办【图文】

    x201换风扇_x201i拆机风扇清理怎么办【图文】总所周知,笔记本室友大大小小的配置组装而成的,而笔记本同样的,有时也会存在着或多或少的故障,又或者有时由于好奇心的趋势,让我们相对笔记本内部的相关配置做更深一步的了解,这个时候,我们会选择对笔记本进行拆机,从而对风扇进行清理,但是我们又怕盲目的拆机有可能会对笔记本造成损坏,那么,x201i拆机风扇清理应该怎么办呢?下面,就让我们来认识一下,x201i拆机风扇清理应该怎么办?笔记本散热风扇使用时间长…

  • dos环境下操作mysql

    dos环境下操作mysqldos环境下操作mysql

  • 基于Android开发的天气预报app(源码下载)「建议收藏」

    基于Android开发的天气预报app(源码下载)「建议收藏」基于AndroidStudio环境开发的天气app-系统总体介绍:本天气app使用AndroidStudio这个IDE工具在Windows10系统下进行开发。主要实现了:1、定位城市天气显示;2、城市编辑功能(增、删、改、查)以及对应天气显示信息的改变;3、天气信息的Widget窗口显示(城市的编辑功能可以远程的更新Widget窗口信息的显示)4、下拉刷新、天气显示界面左右滑动、城市拖拽等小模…

发表回复

您的电子邮箱地址不会被公开。

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